gethostbyname_r(3) may fail to lookup hostname alias over MAXALIASES(>35)

Issue #89 closed
Takehiko NOZAKI repo owner created an issue

recent MFC of gethostent_r(3) <<cset:ff9a0f5>> eliminate limitation of MAXALIASES in /etc/hosts. but gethostbyname_r(3) is still restricted.

$ grep host /etc/hosts
192.0.2.1       host00 host01 host02 host03 host04 host05 host06 host07 host08 host09 \
                host10 host11 host12 host13 host14 host15 host16 host17 host18 host19 \
                host20 host21 host22 host23 host24 host25 host26 host27 host28 host29 \
                host30 host31 host32 host33 host34 host35 host36
$ ping host36
ping: Cannot resolve "host36" (Unknown host)

Comments (5)

  1. Takehiko NOZAKI reporter

    gethostbyname_r(3) still uses static allocated buffer by MAXALIASES.

    153 struct hostent *
    154 _hf_gethtbyname2(const char *name, int af, struct getnamaddr *info)
    155 {
    ...
    160     char *aliases[MAXALIASES];
    ...
    187         hp = gethostent_r(hf, info->hp, info->buf, info->buflen,
    188             info->he);
    ...
    205             for (anum = 0; hp->h_aliases[anum]; anum++) {
    206                 if (anum >= __arraycount(aliases))
    207                     goto nospc;
    208                 HENT_SCOPY(aliases[anum], hp->h_aliases[anum],
    209                     ptr, len);
    210             }
    ...
    
  2. Log in to comment