Subject: c-ares segfault in gehostbyname on windows

c-ares segfault in gehostbyname on windows

From: Jeremy Leibs <leibs_at_suitabletech.com>
Date: Mon, 8 Aug 2011 11:23:37 -0700

I'm running c-ares version 1.7.4

I came across a segfault on Windows in ares_gethostbyname.c in "file_lookup"

The basic problem seems to be that PATH_HOSTS isn't initialized. If the
call to "RegOpenKeyEx" fails, PATH_HOSTS makes it down to "strcat" before
being initialized. If there are no null characters in the first MAX_PATH
characters, strcat copies off the end of the array and things end up
corrupted.

The valid fix is to clear PATH_HOSTS. ares_gethostbyaddr contains the same
code, so I fixed it there as well.

I've attached a very simple patch including the changes.

Thanks,
--Jeremy

Received on 2011-08-08