diff options
author | lteo <> | 2015-01-03 03:03:39 +0000 |
---|---|---|
committer | lteo <> | 2015-01-03 03:03:39 +0000 |
commit | 3a71bbcdc4f61edf763302e9f0114aa00ce81b97 (patch) | |
tree | a7f6ed7b3df7e1dfc65aa90118a927fc102152fd | |
parent | f655ecb73179c3e1df740de75e9127e0b6563a42 (diff) | |
download | openbsd-3a71bbcdc4f61edf763302e9f0114aa00ce81b97.tar.gz openbsd-3a71bbcdc4f61edf763302e9f0114aa00ce81b97.tar.bz2 openbsd-3a71bbcdc4f61edf763302e9f0114aa00ce81b97.zip |
Check the return values of several reallocarray() calls. While here,
also check the return value of an adjacent malloc() call.
ok jsing@
-rw-r--r-- | src/usr.bin/openssl/apps.c | 4 | ||||
-rw-r--r-- | src/usr.bin/openssl/rsautl.c | 10 | ||||
-rw-r--r-- | src/usr.bin/openssl/speed.c | 6 |
3 files changed, 17 insertions, 3 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c index 5a6bb7a2ee..d652abc549 100644 --- a/src/usr.bin/openssl/apps.c +++ b/src/usr.bin/openssl/apps.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: apps.c,v 1.23 2015/01/01 14:28:00 jsing Exp $ */ | 1 | /* $OpenBSD: apps.c,v 1.24 2015/01/03 03:03:39 lteo Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -229,6 +229,8 @@ chopup_args(ARGS *arg, char *buf, int *argc, char **argv[]) | |||
229 | if (arg->count == 0) { | 229 | if (arg->count == 0) { |
230 | arg->count = 20; | 230 | arg->count = 20; |
231 | arg->data = reallocarray(NULL, arg->count, sizeof(char *)); | 231 | arg->data = reallocarray(NULL, arg->count, sizeof(char *)); |
232 | if (arg->data == NULL) | ||
233 | return 0; | ||
232 | } | 234 | } |
233 | for (i = 0; i < arg->count; i++) | 235 | for (i = 0; i < arg->count; i++) |
234 | arg->data[i] = NULL; | 236 | arg->data[i] = NULL; |
diff --git a/src/usr.bin/openssl/rsautl.c b/src/usr.bin/openssl/rsautl.c index 95776d250b..8ce3c0e27c 100644 --- a/src/usr.bin/openssl/rsautl.c +++ b/src/usr.bin/openssl/rsautl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rsautl.c,v 1.3 2014/08/28 14:25:48 jsing Exp $ */ | 1 | /* $OpenBSD: rsautl.c,v 1.4 2015/01/03 03:03:39 lteo Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -248,7 +248,15 @@ rsautl_main(int argc, char **argv) | |||
248 | keysize = RSA_size(rsa); | 248 | keysize = RSA_size(rsa); |
249 | 249 | ||
250 | rsa_in = reallocarray(NULL, keysize, 2); | 250 | rsa_in = reallocarray(NULL, keysize, 2); |
251 | if (rsa_in == NULL) { | ||
252 | BIO_printf(bio_err, "Error allocating memory for input data\n"); | ||
253 | exit(1); | ||
254 | } | ||
251 | rsa_out = malloc(keysize); | 255 | rsa_out = malloc(keysize); |
256 | if (rsa_out == NULL) { | ||
257 | BIO_printf(bio_err, "Error allocating memory for output data\n"); | ||
258 | exit(1); | ||
259 | } | ||
252 | 260 | ||
253 | /* Read the input data */ | 261 | /* Read the input data */ |
254 | rsa_inlen = BIO_read(in, rsa_in, keysize * 2); | 262 | rsa_inlen = BIO_read(in, rsa_in, keysize * 2); |
diff --git a/src/usr.bin/openssl/speed.c b/src/usr.bin/openssl/speed.c index b9eca831ff..e40607f940 100644 --- a/src/usr.bin/openssl/speed.c +++ b/src/usr.bin/openssl/speed.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: speed.c,v 1.3 2015/01/02 04:00:21 lteo Exp $ */ | 1 | /* $OpenBSD: speed.c,v 1.4 2015/01/03 03:03:39 lteo Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -1998,6 +1998,10 @@ do_multi(int multi) | |||
1998 | const char *errstr = NULL; | 1998 | const char *errstr = NULL; |
1999 | 1999 | ||
2000 | fds = reallocarray(NULL, multi, sizeof *fds); | 2000 | fds = reallocarray(NULL, multi, sizeof *fds); |
2001 | if (fds == NULL) { | ||
2002 | fprintf(stderr, "reallocarray failure\n"); | ||
2003 | exit(1); | ||
2004 | } | ||
2001 | for (n = 0; n < multi; ++n) { | 2005 | for (n = 0; n < multi; ++n) { |
2002 | if (pipe(fd) == -1) { | 2006 | if (pipe(fd) == -1) { |
2003 | fprintf(stderr, "pipe failure\n"); | 2007 | fprintf(stderr, "pipe failure\n"); |