fix potential read past end of buffer in getnameinfo host name lookup
authorAlexey Izbyshev <izbyshev@ispras.ru>
Sat, 25 Feb 2023 15:41:32 +0000 (18:41 +0300)
committerRich Felker <dalias@aerifal.cx>
Mon, 27 Feb 2023 15:04:34 +0000 (10:04 -0500)
This is completely analoguous to commit 633183b5d1c2.

Similar code called from __lookup_name is not affected because it checks
that the line contains the host name surrounded by blanks.

src/network/getnameinfo.c

index 080d3c0..7abe0fa 100644 (file)
@@ -58,6 +58,7 @@ static void reverse_hosts(char *buf, const unsigned char *a, unsigned scopeid, i
                if ((p=strchr(line, '#'))) *p++='\n', *p=0;
 
                for (p=line; *p && !isspace(*p); p++);
+               if (!*p) continue;
                *p++ = 0;
                if (__lookup_ipliteral(&iplit, line, AF_UNSPEC)<=0)
                        continue;