diff --git a/ifchd/ifchd.c b/ifchd/ifchd.c index 7b8808d..7bae147 100644 --- a/ifchd/ifchd.c +++ b/ifchd/ifchd.c @@ -374,8 +374,7 @@ static int execute_buffer(struct ifchd_client *cl, char *newbuf) strlcat(buf, cl->ibuf, sizeof buf); strlcat(buf, newbuf, sizeof buf); - for (;;) { - endp = p; + for (endp = p;;p = endp) { if (cl->state == STATE_NOTHING) { char *colon = strchr(p, ':'); if (!colon) @@ -400,6 +399,9 @@ static int execute_buffer(struct ifchd_client *cl, char *newbuf) endp = semi + 1; } + if (!strlen(p)) + continue; + switch (cl->state) { case STATE_NOTHING: if (strncmp(p, CMD_INTERFACE, sizeof(CMD_INTERFACE)) == 0) @@ -506,7 +508,6 @@ static int execute_buffer(struct ifchd_client *cl, char *newbuf) log_line("warning: invalid state in dispatch_work\n"); break; } - p = endp; } size_t remsize = strlen(endp); if (remsize > MAX_BUF - 1) diff --git a/ifchd/linux.c b/ifchd/linux.c index 0cace36..69f501d 100644 --- a/ifchd/linux.c +++ b/ifchd/linux.c @@ -279,6 +279,9 @@ void perform_mtu(struct ifchd_client *cl, char *str) return; mtu = strtol(str, NULL, 10); + // Minimum MTU for physical IPv4 links is 576 octets. + if (mtu < 576) + return; ifrt.ifr_mtu = mtu; strlcpy(ifrt.ifr_name, cl->ifnam, IFNAMSIZ);