• Kuniyuki Iwashima's avatar
    af_unix: Use offsetof() instead of sizeof(). · 755662ce
    Kuniyuki Iwashima authored
    The length of the AF_UNIX socket address contains an offset to the member
    sun_path of struct sockaddr_un.
    
    Currently, the preceding member is just sun_family, and its type is
    sa_family_t and resolved to short.  Therefore, the offset is represented by
    sizeof(short).  However, it is not clear and fragile to changes in struct
    sockaddr_storage or sockaddr_un.
    
    This commit makes it clear and robust by rewriting sizeof() with
    offsetof().
    Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.co.jp>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    755662ce
diag.c 7.48 KB