From 855d0b940101b8b59ac1d75eaab26165ee448490 Mon Sep 17 00:00:00 2001 From: Isidoro Ghezzi Date: Wed, 9 May 2018 09:34:02 +0930 Subject: [PATCH] "sizeof(sun->sun_path)" is not always the same as "sizeof(addr->u.sockname)" on all platforms; because of that BUILD_ASSERT was failing on macOS. (on macOS "sizeof(sun->sun_path) == 104" and "sizeof(addr->u.sockname) == 108") [ Linux man page says it can be as small as 92, so let's use the real value. I also cleaned up the incorrect comment order on that struct! --RR ] Signed-off-by: Rusty Russell --- common/wireaddr.c | 2 -- common/wireaddr.h | 8 +++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/wireaddr.c b/common/wireaddr.c index a5044eba6..f76660901 100644 --- a/common/wireaddr.c +++ b/common/wireaddr.c @@ -8,9 +8,7 @@ #include #include #include -#include #include -#include #include /* Returns false if we didn't parse it, and *cursor == NULL if malformed. */ diff --git a/common/wireaddr.h b/common/wireaddr.h index 994774c01..cfffcfb3c 100644 --- a/common/wireaddr.h +++ b/common/wireaddr.h @@ -5,6 +5,8 @@ #include #include #include +#include +#include struct in6_addr; struct in_addr; @@ -87,12 +89,12 @@ enum wireaddr_internal_type { struct wireaddr_internal { enum wireaddr_internal_type itype; union { - /* ADDR_INTERNAL_SOCKNAME */ + /* ADDR_INTERNAL_WIREADDR */ struct wireaddr wireaddr; /* ADDR_INTERNAL_ALLPROTO */ u16 port; - /* ADDR_INTERNAL_WIREADDR */ - char sockname[108]; + /* ADDR_INTERNAL_SOCKNAME */ + char sockname[sizeof(((struct sockaddr_un *)0)->sun_path)]; } u; }; bool parse_wireaddr_internal(const char *arg, struct wireaddr_internal *addr, u16 port, bool wildcard_ok, const char **err_msg);