]> git.baikalelectronics.ru Git - kernel.git/commit
af_unix: Use offsetof() instead of sizeof().
authorKuniyuki Iwashima <kuniyu@amazon.co.jp>
Wed, 24 Nov 2021 02:14:19 +0000 (11:14 +0900)
committerJakub Kicinski <kuba@kernel.org>
Sat, 27 Nov 2021 02:01:53 +0000 (18:01 -0800)
commitad8c82e1b76b52d8b3ca7110ed10a7abdbed4aac
tree7932aff19cff0e8f89785ba434c9b4f95a3efb19
parent76ba37a6a70fd676688c275329697524064a4306
af_unix: Use offsetof() instead of sizeof().

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: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/unix/af_unix.c
net/unix/diag.c