From: Mark Wooding Date: Sat, 14 May 2016 18:30:10 +0000 (+0100) Subject: sel/bres.c: Don't capture `h->h_name' in non-`const' pointer. X-Git-Tag: 2.2.3~5 X-Git-Url: https://git.distorted.org.uk/~mdw/mLib/commitdiff_plain/47aacebf4528d23b80b6fce06513dbe8e5b914e7 sel/bres.c: Don't capture `h->h_name' in non-`const' pointer. It turns out to be `const' under Cygwin. In fact, we don't need to capture it at all, so restructure the logic so we don't bother trying. --- diff --git a/sel/bres.c b/sel/bres.c index cc44049..22da560 100644 --- a/sel/bres.c +++ b/sel/bres.c @@ -473,38 +473,33 @@ static void child(int rfd, int cfd) if (doread(cfd, &addr, sizeof(addr))) goto lose; if ((h = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET)) == 0) - goto fail; + goto skip; /* --- Do a forward lookup to confirm --- */ { size_t sz = strlen(h->h_name) + 1; if ((p = malloc(sz)) == 0) - goto fail; + goto skip; memcpy(p, h->h_name, sz); } h = gethostbyname(p); free(p); if (!h) - goto fail; - p = 0; + goto skip; if (h) { char **pp; for (pp = h->h_addr_list; *pp; pp++) { struct in_addr a; memcpy(&a, *pp, sizeof(a)); - if (a.s_addr == addr.s_addr) { - p = h->h_name; - break; - } + if (a.s_addr == addr.s_addr) + goto skip; } } - if (!p) { - h = 0; - h_errno = NO_RECOVERY; - } - fail:; + h = 0; + h_errno = NO_RECOVERY; + skip:; } break; /* --- Unknown request -- may have lost sync --- */