ip a: fix SEGV if "dev IFACE" is not specified

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2010-07-04 03:55:43 +02:00
parent 21e8e8da64
commit fd744519d1

View File

@ -681,7 +681,7 @@ static int ipaddr_modify(int cmd, char **argv)
} else if (arg == 7) { /* label */
NEXT_ARG();
l = *argv;
addattr_l(&req.n, sizeof(req), IFA_LABEL, l, strlen(l)+1);
addattr_l(&req.n, sizeof(req), IFA_LABEL, l, strlen(l) + 1);
} else {
if (arg == 8) /* local */
NEXT_ARG();
@ -698,11 +698,10 @@ static int ipaddr_modify(int cmd, char **argv)
argv++;
}
// d cannot be null here, NEXT_ARG() of "dev" ensures that
//if (d == NULL) {
// bb_error_msg(bb_msg_requires_arg, "\"dev\"");
// return -1;
//}
if (!d) {
/* There was no "dev IFACE", but we need that */
bb_error_msg_and_die("need \"dev IFACE\"");
}
if (l && strncmp(d, l, strlen(d)) != 0) {
bb_error_msg_and_die("\"dev\" (%s) must match \"label\" (%s)", d, l);
}