summaryrefslogtreecommitdiff
path: root/src/lib/libssl/s3_lib.c
diff options
context:
space:
mode:
authormiod <>2014-05-26 20:54:06 +0000
committermiod <>2014-05-26 20:54:06 +0000
commitff902a2ab8de41d828e44691e4fcd5e828a0ee2c (patch)
treec839ab4f405bfea1c43fddd81eb73b59b27f5ef3 /src/lib/libssl/s3_lib.c
parentbc3247c8eb23411aa06a89056f623998745a0bb5 (diff)
downloadopenbsd-ff902a2ab8de41d828e44691e4fcd5e828a0ee2c.tar.gz
openbsd-ff902a2ab8de41d828e44691e4fcd5e828a0ee2c.tar.bz2
openbsd-ff902a2ab8de41d828e44691e4fcd5e828a0ee2c.zip
Replace the following logic:
if (nothing to allocate) ptr = malloc(1) else { if ((ptr = malloc(size to allocate)) memcpy(ptr, data to copy, size to allocate) } if (ptr == NULL) OMG ERROR with a saner logic where the NULL pointer check if moved to the actual malloc branch, so that we do not need to malloc a single byte, just to avoid having a NULL pointer. Whoever thought allocating a single byte was a smart idea was obviously not taking his meds. ok beck@ guenther@
Diffstat (limited to 'src/lib/libssl/s3_lib.c')
-rw-r--r--src/lib/libssl/s3_lib.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index 8b67e7c36a..d8a186040b 100644
--- a/src/lib/libssl/s3_lib.c
+++ b/src/lib/libssl/s3_lib.c
@@ -2633,16 +2633,18 @@ ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
2633 if (s->tlsext_opaque_prf_input != NULL) 2633 if (s->tlsext_opaque_prf_input != NULL)
2634 free(s->tlsext_opaque_prf_input); 2634 free(s->tlsext_opaque_prf_input);
2635 if ((size_t)larg == 0) { 2635 if ((size_t)larg == 0) {
2636 /* dummy byte just to get non-NULL */ 2636 s->tlsext_opaque_prf_input = NULL;
2637 s->tlsext_opaque_prf_input = malloc(1); 2637 s->tlsext_opaque_prf_input_len = 0;
2638 } else 2638 ret = 1;
2639 } else {
2639 s->tlsext_opaque_prf_input = 2640 s->tlsext_opaque_prf_input =
2640 BUF_memdup(parg, (size_t)larg); 2641 BUF_memdup(parg, (size_t)larg);
2641 if (s->tlsext_opaque_prf_input != NULL) { 2642 if (s->tlsext_opaque_prf_input != NULL) {
2642 s->tlsext_opaque_prf_input_len = (size_t)larg; 2643 s->tlsext_opaque_prf_input_len = (size_t)larg;
2643 ret = 1; 2644 ret = 1;
2644 } else 2645 } else
2645 s->tlsext_opaque_prf_input_len = 0; 2646 s->tlsext_opaque_prf_input_len = 0;
2647 }
2646 break; 2648 break;
2647#endif 2649#endif
2648 2650