diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2016-02-24 20:52:54 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2016-02-24 20:52:54 +0000 |
commit | d0b4306745abae9d5f5a95b07b32fa6e7a4ffd8a (patch) | |
tree | 4ec6b9c25570cf37c7e54cb7753d4c35d027f723 /lib/libc | |
parent | 726e00973f65caf27e19150b510b31ceb32f8f05 (diff) |
Avoid a possible double-free if the "search" keyword is used multiple times.
ok jca@ gilles@
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/asr/asr.c | 6 |
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]); |