Enforce minimum physical MTU in ifchd.

Skip zero-length commands in execute_buffer().
This commit is contained in:
Nicholas J. Kain 2012-07-20 20:37:41 -04:00
parent 2bf7306bb9
commit 87db9c70fd
2 changed files with 7 additions and 3 deletions

View File

@ -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)

View File

@ -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);