Fix checking the return value of getentropy()

Reviewed-by: Andy Polyakov <appro@openssl.org>
GH: #6405
This commit is contained in:
Kurt Roeckx 2018-06-02 18:15:32 +02:00
parent 2545f9446e
commit 1e653d0ff7

View file

@ -249,7 +249,7 @@ int syscall_random(void *buf, size_t buflen)
*/
p_getentropy.p = DSO_global_lookup("getentropy");
if (p_getentropy.p != NULL)
return p_getentropy.f(buf, buflen);
return p_getentropy.f(buf, buflen) == 0 ? buflen : 0;
/* Linux supports this since version 3.17 */
# if defined(__linux) && defined(SYS_getrandom)