mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-27 12:05:15 +00:00
snprintf() is a macro on some operating systems
and having #ifdef statements in macro parameters has undefined behavior.
This commit is contained in:
parent
b31e66343a
commit
1523a4f035
12
src/tun.c
12
src/tun.c
@ -449,6 +449,7 @@ tun_setip(const char *ip, const char *other_ip, int netbits)
|
|||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
DWORD len;
|
DWORD len;
|
||||||
#endif
|
#endif
|
||||||
|
const char *display_ip;
|
||||||
|
|
||||||
netmask = 0;
|
netmask = 0;
|
||||||
for (i = 0; i < netbits; i++) {
|
for (i = 0; i < netbits; i++) {
|
||||||
@ -462,15 +463,16 @@ tun_setip(const char *ip, const char *other_ip, int netbits)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#ifndef WINDOWS32
|
#ifndef WINDOWS32
|
||||||
|
# ifdef FREEBSD
|
||||||
|
display_ip = other_ip; /* FreeBSD wants other IP as second IP */
|
||||||
|
# else
|
||||||
|
display_ip = ip;
|
||||||
|
# endif
|
||||||
snprintf(cmdline, sizeof(cmdline),
|
snprintf(cmdline, sizeof(cmdline),
|
||||||
IFCONFIGPATH "ifconfig %s %s %s netmask %s",
|
IFCONFIGPATH "ifconfig %s %s %s netmask %s",
|
||||||
if_name,
|
if_name,
|
||||||
ip,
|
ip,
|
||||||
#ifdef FREEBSD
|
display_ip,
|
||||||
other_ip, /* FreeBSD wants other IP as second IP */
|
|
||||||
#else
|
|
||||||
ip,
|
|
||||||
#endif
|
|
||||||
inet_ntoa(net));
|
inet_ntoa(net));
|
||||||
|
|
||||||
fprintf(stderr, "Setting IP of %s to %s\n", if_name, ip);
|
fprintf(stderr, "Setting IP of %s to %s\n", if_name, ip);
|
||||||
|
Loading…
Reference in New Issue
Block a user