wg: chill modern gcc out
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
ff52c3e3a4
commit
3338bb11e8
28
src/config.c
28
src/config.c
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -220,7 +221,7 @@ static inline bool parse_ipmasks(struct inflatable_device *buf, size_t peer_offs
|
||||||
}
|
}
|
||||||
sep = mutable;
|
sep = mutable;
|
||||||
while ((mask = strsep(&sep, ","))) {
|
while ((mask = strsep(&sep, ","))) {
|
||||||
unsigned long cidr;
|
unsigned long cidr = ULONG_MAX;
|
||||||
char *end, *ip = strsep(&mask, "/");
|
char *end, *ip = strsep(&mask, "/");
|
||||||
if (use_space(buf, sizeof(struct wgipmask)) < 0) {
|
if (use_space(buf, sizeof(struct wgipmask)) < 0) {
|
||||||
perror("use_space");
|
perror("use_space");
|
||||||
|
@ -234,27 +235,16 @@ static inline bool parse_ipmasks(struct inflatable_device *buf, size_t peer_offs
|
||||||
free(mutable);
|
free(mutable);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (ipmask->family == AF_INET) {
|
if (mask && *mask) {
|
||||||
if (mask) {
|
|
||||||
cidr = strtoul(mask, &end, 10);
|
cidr = strtoul(mask, &end, 10);
|
||||||
if (*end)
|
if (*end)
|
||||||
mask = NULL;
|
cidr = ULONG_MAX;
|
||||||
if (cidr > 32)
|
|
||||||
mask = NULL;
|
|
||||||
}
|
}
|
||||||
if (!mask)
|
if (ipmask->family == AF_INET)
|
||||||
cidr = 32;
|
cidr = cidr > 32 ? 32 : cidr;
|
||||||
} else if (ipmask->family == AF_INET6) {
|
else if (ipmask->family == AF_INET6)
|
||||||
if (mask) {
|
cidr = cidr > 128 ? 128 : cidr;
|
||||||
cidr = strtoul(mask, &end, 10);
|
else
|
||||||
if (*end)
|
|
||||||
mask = NULL;
|
|
||||||
if (cidr > 128)
|
|
||||||
mask = NULL;
|
|
||||||
}
|
|
||||||
if (!mask)
|
|
||||||
cidr = 128;
|
|
||||||
} else
|
|
||||||
continue;
|
continue;
|
||||||
ipmask->cidr = cidr;
|
ipmask->cidr = cidr;
|
||||||
++peer->num_ipmasks;
|
++peer->num_ipmasks;
|
||||||
|
|
Loading…
Reference in New Issue