From: Ian Jackson Date: Sat, 19 Nov 2016 19:41:06 +0000 (+0000) Subject: setup.c: Do not fail assertion if `search' with no options in resolv.conf X-Git-Tag: adns-1.5.2~19 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=8fbc5b14a8b960b8e1c865ade0fba390adc6fefd;p=adns.git setup.c: Do not fail assertion if `search' with no options in resolv.conf (Found by AFL.) Signed-off-by: Ian Jackson --- diff --git a/src/setup.c b/src/setup.c index 8ff92d2..54b93a8 100644 --- a/src/setup.c +++ b/src/setup.c @@ -147,11 +147,17 @@ static void ccf_search(adns_state ads, const char *fn, tl= 0; while (nextword(&bufp,&word,&l)) { count++; tl += l+1; } - newptrs= malloc(sizeof(char*)*count); - if (!newptrs) { saveerr(ads,errno); return; } - - newchars= malloc(tl); - if (!newchars) { saveerr(ads,errno); free(newptrs); return; } + if (count) { + newptrs= malloc(sizeof(char*)*count); + if (!newptrs) { saveerr(ads,errno); return; } + + newchars= malloc(tl); + if (!newchars) { saveerr(ads,errno); free(newptrs); return; } + } else { + assert(!tl); + newptrs= 0; + newchars= 0; + } bufp= buf; pp= newptrs;