Skip to content

Commit b36a615

Browse files
committed
rand: fix error check of RAND_load_file()
This function returns -1 on error, or the number of bytes read on success. Preserve current behaviour and also error out on error. Discovered by an experimental static analyzer I work on.
1 parent 9796ee8 commit b36a615

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

ext/openssl/ossl_rand.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ ossl_rand_add(VALUE self, VALUE str, VALUE entropy)
6767
static VALUE
6868
ossl_rand_load_file(VALUE self, VALUE filename)
6969
{
70-
if(!RAND_load_file(StringValueCStr(filename), -1)) {
70+
if (RAND_load_file(StringValueCStr(filename), -1) < 0) {
7171
ossl_raise(eRandomError, NULL);
7272
}
7373
return Qtrue;

0 commit comments

Comments
 (0)