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

From: Kris Kennaway (kris_at_obsecurity.org)
Date: 06/16/03

  • Next message: Craig Boston: "Multiple cardbus devices? (RFI)"
    Date: Sun, 15 Jun 2003 18:54:59 -0700
    To: current@FreeBSD.org, julian@FreeBSD.org
    
    
    

    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 message: Craig Boston: "Multiple cardbus devices? (RFI)"

    Relevant Pages

    • Re: Are static array pointers thread safe?
      ... implementation, using the value a twice, once as the array name, once as a parameter) ... pointers thread safe /NT". ... checked by the read-write functions using an enum or static const int ... MVP Tips:http://www.flounder.com/mvp_tips.htm ...
      (microsoft.public.vc.mfc)
    • Re: Are static array pointers thread safe?
      ... implementation, using the value a twice, once as the array name, once as a parameter) ... pointers thread safe /NT". ... would affect the correctness of the access to the data, ... checked by the read-write functions using an enum or static const int ...
      (microsoft.public.vc.mfc)
    • Re: Are static array pointers thread safe?
      ... implementation, using the value a twice, once as the array name, once as a parameter) ... Depends on what you mean by "thread safe". ... I presume the goal is a singleton class. ... checked by the read-write functions using an enum or static const int ...
      (microsoft.public.vc.mfc)