aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-07-04 03:55:43 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-07-04 03:55:43 +0200
commitfd744519d1e848c4760c23805bf993396b19c8b2 (patch)
treeeff0905b9d1cc1fdac330c88ee988c53efdb2db7
parent21e8e8da6483c80a6054b06e48341968a7dccdd5 (diff)
downloadbusybox-w32-fd744519d1e848c4760c23805bf993396b19c8b2.tar.gz
busybox-w32-fd744519d1e848c4760c23805bf993396b19c8b2.tar.bz2
busybox-w32-fd744519d1e848c4760c23805bf993396b19c8b2.zip
ip a: fix SEGV if "dev IFACE" is not specified
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/libiproute/ipaddress.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index a603053e1..381293412 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -444,28 +444,28 @@ int ipaddr_list_or_flush(char **argv, int flush)
444 while (*argv) { 444 while (*argv) {
445 const smalluint key = index_in_strings(option, *argv); 445 const smalluint key = index_in_strings(option, *argv);
446 if (key == 0) { /* to */ 446 if (key == 0) { /* to */
447 NEXT_ARG(); 447 NEXT_ARG();
448 get_prefix(&G_filter.pfx, *argv, G_filter.family); 448 get_prefix(&G_filter.pfx, *argv, G_filter.family);
449 if (G_filter.family == AF_UNSPEC) { 449 if (G_filter.family == AF_UNSPEC) {
450 G_filter.family = G_filter.pfx.family; 450 G_filter.family = G_filter.pfx.family;
451 } 451 }
452 } else if (key == 1) { /* scope */ 452 } else if (key == 1) { /* scope */
453 uint32_t scope = 0; 453 uint32_t scope = 0;
454 NEXT_ARG(); 454 NEXT_ARG();
455 G_filter.scopemask = -1; 455 G_filter.scopemask = -1;
456 if (rtnl_rtscope_a2n(&scope, *argv)) { 456 if (rtnl_rtscope_a2n(&scope, *argv)) {
457 if (strcmp(*argv, "all") != 0) { 457 if (strcmp(*argv, "all") != 0) {
458 invarg(*argv, "scope"); 458 invarg(*argv, "scope");
459 }
460 scope = RT_SCOPE_NOWHERE;
461 G_filter.scopemask = 0;
462 } 459 }
463 G_filter.scope = scope; 460 scope = RT_SCOPE_NOWHERE;
461 G_filter.scopemask = 0;
462 }
463 G_filter.scope = scope;
464 } else if (key == 2) { /* up */ 464 } else if (key == 2) { /* up */
465 G_filter.up = 1; 465 G_filter.up = 1;
466 } else if (key == 3) { /* label */ 466 } else if (key == 3) { /* label */
467 NEXT_ARG(); 467 NEXT_ARG();
468 G_filter.label = *argv; 468 G_filter.label = *argv;
469 } else { 469 } else {
470 if (key == 4) /* dev */ 470 if (key == 4) /* dev */
471 NEXT_ARG(); 471 NEXT_ARG();
@@ -681,7 +681,7 @@ static int ipaddr_modify(int cmd, char **argv)
681 } else if (arg == 7) { /* label */ 681 } else if (arg == 7) { /* label */
682 NEXT_ARG(); 682 NEXT_ARG();
683 l = *argv; 683 l = *argv;
684 addattr_l(&req.n, sizeof(req), IFA_LABEL, l, strlen(l)+1); 684 addattr_l(&req.n, sizeof(req), IFA_LABEL, l, strlen(l) + 1);
685 } else { 685 } else {
686 if (arg == 8) /* local */ 686 if (arg == 8) /* local */
687 NEXT_ARG(); 687 NEXT_ARG();
@@ -698,11 +698,10 @@ static int ipaddr_modify(int cmd, char **argv)
698 argv++; 698 argv++;
699 } 699 }
700 700
701 // d cannot be null here, NEXT_ARG() of "dev" ensures that 701 if (!d) {
702 //if (d == NULL) { 702 /* There was no "dev IFACE", but we need that */
703 // bb_error_msg(bb_msg_requires_arg, "\"dev\""); 703 bb_error_msg_and_die("need \"dev IFACE\"");
704 // return -1; 704 }
705 //}
706 if (l && strncmp(d, l, strlen(d)) != 0) { 705 if (l && strncmp(d, l, strlen(d)) != 0) {
707 bb_error_msg_and_die("\"dev\" (%s) must match \"label\" (%s)", d, l); 706 bb_error_msg_and_die("\"dev\" (%s) must match \"label\" (%s)", d, l);
708 } 707 }