Add compile time sanity check for interface name lengths.

Because our interfaces include UNIX domain sockets, we are using
UNIX_PATH_MAX of 108 bytes for our interface names.  Even though
IF_NAMESIZE is much smaller (16 bytes), there is nothing that
guarantees this.  This patch adds a compile time sanity check that
tests whether the interface name will fit.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2017-10-14 06:02:14 -07:00
parent d513ecac9c
commit 20a229e168
1 changed files with 4 additions and 0 deletions

View File

@ -32,6 +32,10 @@
#define MAX_IFNAME_SIZE 108 /* = UNIX_PATH_MAX */ #define MAX_IFNAME_SIZE 108 /* = UNIX_PATH_MAX */
#if (IF_NAMESIZE > MAX_IFNAME_SIZE)
#error if_namesize larger than expected.
#endif
/** Defines a network interface, with PTP options. */ /** Defines a network interface, with PTP options. */
struct interface { struct interface {
STAILQ_ENTRY(interface) list; STAILQ_ENTRY(interface) list;