diff options
author | tb <tb@openbsd.org> | 2019-04-13 18:47:58 +0000 |
---|---|---|
committer | tb <tb@openbsd.org> | 2019-04-13 18:47:58 +0000 |
commit | 0f235647877a526523961ad0c5962410ae3a942b (patch) | |
tree | 89892455a708c03f12bb22b5a99de0156a7f46e9 /lib/libtls | |
parent | Avoid quadratic behavior of decimal BIGNUM conversion (diff) | |
download | wireguard-openbsd-0f235647877a526523961ad0c5962410ae3a942b.tar.xz wireguard-openbsd-0f235647877a526523961ad0c5962410ae3a942b.zip |
Null out pointers on asprintf() failure.
These pointers will be passed to free. According to asprintf(3), "on
OpenBSD, ret will be set to the null pointer, but this behavior should
not be relied upon."
ok jsing
Diffstat (limited to 'lib/libtls')
-rw-r--r-- | lib/libtls/tls_util.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libtls/tls_util.c b/lib/libtls/tls_util.c index 3ca3ecad0ba..b144fb1eaed 100644 --- a/lib/libtls/tls_util.c +++ b/lib/libtls/tls_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_util.c,v 1.13 2019/04/04 15:10:10 jsing Exp $ */ +/* $OpenBSD: tls_util.c,v 1.14 2019/04/13 18:47:58 tb Exp $ */ /* * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> @@ -102,10 +102,14 @@ tls_host_port(const char *hostport, char **host, char **port) *p++ = '\0'; - if (asprintf(host, "%s", h) == -1) + if (asprintf(host, "%s", h) == -1) { + *host = NULL; goto err; - if (asprintf(port, "%s", p) == -1) + } + if (asprintf(port, "%s", p) == -1) { + *port = NULL; goto err; + } rv = 0; goto done; |