summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2019-09-25 14:41:41 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2019-09-25 14:41:41 +0000
commit9be943426ae7c786e43537b6231656cb42db1460 (patch)
tree2781d5549173d2b1c5f284e626ca1936de77f4cf /sbin
parent6d308f9f40b8787442a87ffa333d7de2eb864362 (diff)
Do not leak cur_ns in case of malformed lease file.
Found by llvm's scan-build. OK deraadt, benno
Diffstat (limited to 'sbin')
-rw-r--r--sbin/unwind/frontend.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sbin/unwind/frontend.c b/sbin/unwind/frontend.c
index 4ed5f5d2e64..9532e1ce0ff 100644
--- a/sbin/unwind/frontend.c
+++ b/sbin/unwind/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.23 2019/09/25 14:40:59 florian Exp $ */
+/* $OpenBSD: frontend.c,v 1.24 2019/09/25 14:41:40 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -1018,6 +1018,7 @@ parse_dhcp_lease(int fd)
if (strcmp(toks[1], "domain-name-servers") == 0) {
if((p = strchr(toks[2], ';')) != NULL) {
*p='\0';
+ free(cur_ns);
cur_ns = strdup(toks[2]);
}
}
@@ -1041,11 +1042,16 @@ parse_dhcp_lease(int fd)
if (epoch + lease_time > now ) {
free(ns);
ns = cur_ns;
- } else /* expired lease */
+ cur_ns = NULL;
+ } else {
+ /* expired lease */
free(cur_ns);
+ cur_ns = NULL;
+ }
}
}
free(line);
+ free(cur_ns);
if (ferror(f))
log_warn("getline");