Bogus "temporary" gethostbyaddr_r() in libc for 6 years

Kris Kennaway kris at obsecurity.org
Sun Jun 15 18:55:00 PDT 2003


There's a bogus implementation of gethostbyaddr_r() in
lib/libc/net/gethostnamadr.c that was committed 6 years and nine
months ago:

/*
 * Temporary function (not thread safe)
 */
int gethostbyaddr_r(const char *addr, int len, int type,
        struct hostent *result, struct hostent_data *buffer)
{
        struct hostent *hp;
        int ret;
        if ((hp = gethostbyaddr(addr, len, type)) == NULL) {
                ret = -1;
        } else {
                memcpy(result, hp, sizeof(struct hostent));
                ret = 0;
        }
        return(ret);
}

What's the deal here? Despite the fact that this is not prototyped in
a header, some ports are detecting this, and -- one assumes -- not
behaving correctly since this implementation isn't thread-safe.

Kris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20030615/2a4b3804/attachment.bin


More information about the freebsd-current mailing list