diff options
author | jsing <jsing@openbsd.org> | 2019-04-04 15:10:10 +0000 |
---|---|---|
committer | jsing <jsing@openbsd.org> | 2019-04-04 15:10:10 +0000 |
commit | a2b2c5372fe238427b48cf679d060e81e6eaa40d (patch) | |
tree | 1fba435d0cf93fe4daa0fd029d3bfaf35915514b /lib/libtls | |
parent | Switch to pthread_mutex_init(). (diff) | |
download | wireguard-openbsd-a2b2c5372fe238427b48cf679d060e81e6eaa40d.tar.xz wireguard-openbsd-a2b2c5372fe238427b48cf679d060e81e6eaa40d.zip |
Only assign destlen when src is non-NULL.
This avoids ever having a non-zero len with a NULL pointer.
Diffstat (limited to 'lib/libtls')
-rw-r--r-- | lib/libtls/tls_util.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libtls/tls_util.c b/lib/libtls/tls_util.c index b964f651218..3ca3ecad0ba 100644 --- a/lib/libtls/tls_util.c +++ b/lib/libtls/tls_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_util.c,v 1.12 2018/02/08 07:55:29 jsing Exp $ */ +/* $OpenBSD: tls_util.c,v 1.13 2019/04/04 15:10:10 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> @@ -43,10 +43,11 @@ tls_set_mem(char **dest, size_t *destlen, const void *src, size_t srclen) free(*dest); *dest = NULL; *destlen = 0; - if (src != NULL) + if (src != NULL) { if ((*dest = memdup(src, srclen)) == NULL) return -1; - *destlen = srclen; + *destlen = srclen; + } return 0; } |