Skip to content
Snippets Groups Projects
Commit 8afc3b25 authored by Peter A. Jonsson's avatar Peter A. Jonsson
Browse files

rpl-border-router: fix GCC 8 warnings

GCC 8 added the -Wstringop-truncation warning
which makes the regression tests fail on recent
versions of Ubuntu. Silence the compiler by
copying one character less, and add an explicit
null termination afterwards when required.
parent 3ca1340b
No related branches found
No related tags found
No related merge requests found
...@@ -175,7 +175,8 @@ PT_THREAD(handle_input(struct httpd_state *s)) ...@@ -175,7 +175,8 @@ PT_THREAD(handle_input(struct httpd_state *s))
s->filename[sizeof(s->filename) - 1] = '\0'; s->filename[sizeof(s->filename) - 1] = '\0';
} else { } else {
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0; s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
strncpy(s->filename, s->inputbuf, sizeof(s->filename)); strncpy(s->filename, s->inputbuf, sizeof(s->filename) - 1);
s->filename[sizeof(s->filename) - 1] = '\0';
} }
#endif /* URLCONV */ #endif /* URLCONV */
......
...@@ -97,10 +97,11 @@ slip_config_handle_arguments(int argc, char **argv) ...@@ -97,10 +97,11 @@ slip_config_handle_arguments(int argc, char **argv)
case 't': case 't':
if(strncmp("/dev/", optarg, 5) == 0) { if(strncmp("/dev/", optarg, 5) == 0) {
strncpy(slip_config_tundev, optarg + 5, sizeof(slip_config_tundev)); strncpy(slip_config_tundev, optarg + 5, sizeof(slip_config_tundev) - 1);
} else { } else {
strncpy(slip_config_tundev, optarg, sizeof(slip_config_tundev)); strncpy(slip_config_tundev, optarg, sizeof(slip_config_tundev) - 1);
} }
slip_config_tundev[sizeof(slip_config_tundev) - 1] = '\0';
break; break;
case 'a': case 'a':
......
...@@ -165,7 +165,7 @@ tun_alloc(char *dev) ...@@ -165,7 +165,7 @@ tun_alloc(char *dev)
*/ */
ifr.ifr_flags = IFF_TUN | IFF_NO_PI; ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
if(*dev != 0) { if(*dev != 0) {
strncpy(ifr.ifr_name, dev, IFNAMSIZ); strncpy(ifr.ifr_name, dev, IFNAMSIZ - 1);
} }
if((err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0) { if((err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment