summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--random.c4
2 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 0699c13..3b7a23b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jul 7 16:39:04 2015 Eric Wong <e@80x24.org>
+
+ * random.c (fill_random_bytes_syscall): return -1 for error
+ * random.c (fill_random_bytes): try urandom on syscall failure
+
Tue Jul 7 15:02:18 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_str_normalize_ospath): skip invalid byte sequence not
diff --git a/random.c b/random.c
index 853c287..b66f5cb 100644
--- a/random.c
+++ b/random.c
@@ -529,7 +529,7 @@ fill_random_bytes_syscall(void *seed, size_t size)
}
if ((size_t)ret == size) return 0;
}
- return 0;
+ return -1;
}
#else
# define fill_random_bytes_syscall(seed, size) -1
@@ -539,7 +539,7 @@ static int
fill_random_bytes(void *seed, size_t size)
{
int ret = fill_random_bytes_syscall(seed, size);
- if (ret) return ret;
+ if (ret == 0) return ret;
return fill_random_bytes_urandom(seed, size);
}