Re: [PATCH] Workaround for ai_canonname sometimes coming back as null
From: Alex Riesen <hidden>
Date: 2016-06-15 22:46:41
2009/4/29 Augie Fackler [off-list ref]:
On Apr 29, 2009, at 4:55 PM, Alex Riesen wrote:quoted
2009/4/29 Augie Fackler [off-list ref]:quoted
@@ -459,7 +459,10 @@ static void parse_extra_args(char *extra_args, intbuflen) inet_ntop(AF_INET, &sin_addr->sin_addr, addrbuf, sizeof(addrbuf)); free(canon_hostname); - canon_hostname = xstrdup(ai->ai_canonname); + if (ai->ai_canonname) + canon_hostname = xstrdup(ai->ai_canonname); + else + canon_hostname = "unknown";This last line will crash some lines down, when canon_hostname is free'd:Odd, because I'm running with that exact code and not seeing the problem. Should I resubmit an updated patch that xstrdup's unknown into canon_hostname?
I think you can just let canon_hostname be NULL (i.e. don't strdup it, if ai_canonname is NULL). NULL values of canon_hostname seem to be handled just fine: see path_ok and strbuf_expand_dict_cb (strbuf.c)