summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2019-04-13 18:47:58 +0000
committertb <>2019-04-13 18:47:58 +0000
commit1283f6a389dc6bc8c9194cb5bebce31d11fa9243 (patch)
treed5663c0adea792f2bf9447c77b0e24b3e6278b5d
parent72fa0e445948a698471c35be00d67bf6c770dd65 (diff)
downloadopenbsd-1283f6a389dc6bc8c9194cb5bebce31d11fa9243.tar.gz
openbsd-1283f6a389dc6bc8c9194cb5bebce31d11fa9243.tar.bz2
openbsd-1283f6a389dc6bc8c9194cb5bebce31d11fa9243.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
-rw-r--r--src/lib/libtls/tls_util.c10
1 files changed, 7 insertions, 3 deletions
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 @@
1/* $OpenBSD: tls_util.c,v 1.13 2019/04/04 15:10:10 jsing Exp $ */ 1/* $OpenBSD: tls_util.c,v 1.14 2019/04/13 18:47:58 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 4 * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
@@ -102,10 +102,14 @@ tls_host_port(const char *hostport, char **host, char **port)
102 102
103 *p++ = '\0'; 103 *p++ = '\0';
104 104
105 if (asprintf(host, "%s", h) == -1) 105 if (asprintf(host, "%s", h) == -1) {
106 *host = NULL;
106 goto err; 107 goto err;
107 if (asprintf(port, "%s", p) == -1) 108 }
109 if (asprintf(port, "%s", p) == -1) {
110 *port = NULL;
108 goto err; 111 goto err;
112 }
109 113
110 rv = 0; 114 rv = 0;
111 goto done; 115 goto done;