From 22aa80a8806f00247678b585c491dcd94a5e7b3f Mon Sep 17 00:00:00 2001 From: tb <> Date: Sat, 13 Apr 2019 18:47:58 +0000 Subject: 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 --- src/lib/libtls/tls_util.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lib/libtls/tls_util.c b/src/lib/libtls/tls_util.c index 3ca3ecad0b..b144fb1eae 100644 --- a/src/lib/libtls/tls_util.c +++ b/src/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 * Copyright (c) 2014 Ted Unangst @@ -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; -- cgit v1.2.3-55-g6feb