summaryrefslogtreecommitdiffstats
path: root/lib/libc/asr/asr.c
diff options
context:
space:
mode:
authoreric <eric@openbsd.org>2016-02-24 20:52:53 +0000
committereric <eric@openbsd.org>2016-02-24 20:52:53 +0000
commit365b8ebf7e5f5ef9cd3ec904b09c032250e9afa4 (patch)
tree45de8ff4be51b9da1fa422bfa0cb705756a0f7e5 /lib/libc/asr/asr.c
parentRestore validity checks for the disklabels read from disk. They (diff)
downloadwireguard-openbsd-365b8ebf7e5f5ef9cd3ec904b09c032250e9afa4.tar.xz
wireguard-openbsd-365b8ebf7e5f5ef9cd3ec904b09c032250e9afa4.zip
Avoid a possible double-free if the "search" keyword is used multiple times.
ok jca@ gilles@
Diffstat (limited to 'lib/libc/asr/asr.c')
-rw-r--r--lib/libc/asr/asr.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/asr/asr.c b/lib/libc/asr/asr.c
index 7095b9200a1..36fd724e8cb 100644
--- a/lib/libc/asr/asr.c
+++ b/lib/libc/asr/asr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr.c,v 1.50 2015/12/16 16:32:30 deraadt Exp $ */
+/* $OpenBSD: asr.c,v 1.51 2016/02/24 20:52:53 eric Exp $ */
/*
* Copyright (c) 2010-2012 Eric Faurot <eric@openbsd.org>
*
@@ -565,8 +565,10 @@ pass0(char **tok, int n, struct asr_ctx *ac)
}
} else if (!strcmp(tok[0], "search")) {
/* resolv.conf says the last line wins */
- for (i = 0; i < ASR_MAXDOM; i++)
+ for (i = 0; i < ASR_MAXDOM; i++) {
free(ac->ac_dom[i]);
+ ac->ac_dom[i] = NULL;
+ }
ac->ac_domcount = 0;
for (i = 1; i < n; i++)
asr_ctx_add_searchdomain(ac, tok[i]);