Skip to content

Commit

Permalink
"sizeof(sun->sun_path)" is not always the same as "sizeof(addr->u.soc…
Browse files Browse the repository at this point in the history
…kname)"

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 <[email protected]>
  • Loading branch information
isghe authored and rustyrussell committed May 9, 2018
1 parent c33bbb2 commit 855d0b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 0 additions & 2 deletions common/wireaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include <common/wireaddr.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
#include <wire/wire.h>

/* Returns false if we didn't parse it, and *cursor == NULL if malformed. */
Expand Down
8 changes: 5 additions & 3 deletions common/wireaddr.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <ccan/tal/tal.h>
#include <stdbool.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/un.h>

struct in6_addr;
struct in_addr;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 855d0b9

Please sign in to comment.