• Athanasios Douitsis's avatar
    Prevent null pointer exception for h->ai_canonname · 473a6a66
    Athanasios Douitsis authored
    The getaddrinfo call in line 54 sets &h to a struct addrinfo. If a
    canonical name cannot be found for the node argument of getaddrinfo,
    h->ai_canonname is set to NULL. In that case, the strchr call in line
    58 can lead to segfault. This behavior was observed on a macos sierra
    while the hostname was (unfortunately this happens quite
    often in macos).
    The fix is simple, just check h->ai_canonname for the NULL value.
getdomain.c 1.84 KB