[LLVMbugs] [Bug 10871] New: -Warray-bounds fires on usr/include/socket.h ipv6 sockaddr usage

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Sep 6 09:32:55 PDT 2011


           Summary: -Warray-bounds fires on usr/include/socket.h ipv6
                    sockaddr usage
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu

>From  /Developer/SDKs/MacOSX10.6.sdk/usr/include/sys/socket.h:

struct sockaddr {
    __uint8_t    sa_len;        /* total length */
    sa_family_t    sa_family;    /* [XSI] address family */
    char        sa_data[14];    /* [XSI] addr value (actually larger) */

For ipv6 ( in6.h somewhere in Kernel.frameworkl ):

struct in6_addr {
    union {
        __uint8_t   __u6_addr8[16];
        __uint16_t  __u6_addr16[8];
        __uint32_t  __u6_addr32[4];
    } __u6_addr;            /* 128-bit IP6 address */

struct sockaddr_in6 {
    __uint8_t    sin6_len;    /* length of this struct(sa_family_t)*/
    sa_family_t    sin6_family;    /* AF_INET6 (sa_family_t) */
    in_port_t    sin6_port;    /* Transport layer port # (in_port_t)*/
    __uint32_t    sin6_flowinfo;    /* IP6 flow information */
    struct in6_addr    sin6_addr;    /* IP6 address */
    __uint32_t    sin6_scope_id;    /* scope zone index */

Given `sockaddr* myaddr = ...`, if myaddr->sa_family == AF_INET6, then
accessing myaddr->sa_data[6 + 15] is valid (it's some byte of the in6_addr),
yet clang warns " warning: array index of '21' indexes past the end of an array
(that contains 14 elements) [-Warray-bounds]".

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list