diff options
author | Rich Salz <rsalz@openssl.org> | 2016-05-29 20:11:44 +0200 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2016-06-01 16:45:18 +0200 |
commit | 0f91e1dff4ab2e7c25bbae5a48dfabbd1a4eae3c (patch) | |
tree | 96afa283b997bd9ded6976cb2e9b1f7bd351e8ce /apps/rand.c | |
parent | Ensure an ASN1_OBJECT is freed in error paths (diff) | |
download | openssl-0f91e1dff4ab2e7c25bbae5a48dfabbd1a4eae3c.tar.xz openssl-0f91e1dff4ab2e7c25bbae5a48dfabbd1a4eae3c.zip |
Fix some RAND bugs
RT2630 -- segfault for int overlow
RT2877 -- check return values in apps/rand
Update CHANGES file for previous "windows rand" changes.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'apps/rand.c')
-rw-r--r-- | apps/rand.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/apps/rand.c b/apps/rand.c index 89a23a293a..d60f1ecf86 100644 --- a/apps/rand.c +++ b/apps/rand.c @@ -105,22 +105,26 @@ int rand_main(int argc, char **argv) r = RAND_bytes(buf, chunk); if (r <= 0) goto end; - if (format != FORMAT_TEXT) /* hex */ - BIO_write(out, buf, chunk); - else { + if (format != FORMAT_TEXT) { + if (BIO_write(out, buf, chunk) != chunk) + goto end; + } else { for (i = 0; i < chunk; i++) - BIO_printf(out, "%02x", buf[i]); + if (BIO_printf(out, "%02x", buf[i]) != 2) + goto end; } num -= chunk; } if (format == FORMAT_TEXT) BIO_puts(out, "\n"); - (void)BIO_flush(out); + if (BIO_flush(out) <= 0 || !app_RAND_write_file(NULL)) + goto end; - app_RAND_write_file(NULL); ret = 0; end: + if (ret != 0) + ERR_print_errors(bio_err); BIO_free_all(out); return (ret); } |