diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-08-12 16:52:00 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-08-12 16:52:00 +0000 |
commit | 9940e081c92ccf6e2ac172021b73663330c6167d (patch) | |
tree | 9b47cb737f114afb5e10c2e09e52b84840aec726 | |
parent | 4014ab1c6072bc6c2e9604c06960779b191ee566 (diff) | |
download | busybox-w32-9940e081c92ccf6e2ac172021b73663330c6167d.tar.gz busybox-w32-9940e081c92ccf6e2ac172021b73663330c6167d.tar.bz2 busybox-w32-9940e081c92ccf6e2ac172021b73663330c6167d.zip |
Patch from solar to fix problems with get_name()
-rw-r--r-- | libbb/interface.c | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/libbb/interface.c b/libbb/interface.c index f3655b0e0..4632e2930 100644 --- a/libbb/interface.c +++ b/libbb/interface.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * that either displays or sets the characteristics of | 15 | * that either displays or sets the characteristics of |
16 | * one or more of the system's networking interfaces. | 16 | * one or more of the system's networking interfaces. |
17 | * | 17 | * |
18 | * Version: $Id: interface.c,v 1.23 2004/07/23 01:49:46 bug1 Exp $ | 18 | * Version: $Id: interface.c,v 1.24 2004/08/12 16:52:00 andersen Exp $ |
19 | * | 19 | * |
20 | * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> | 20 | * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> |
21 | * and others. Copyright 1993 MicroWalt Corporation | 21 | * and others. Copyright 1993 MicroWalt Corporation |
@@ -986,31 +986,36 @@ static int if_readconf(void) | |||
986 | return err; | 986 | return err; |
987 | } | 987 | } |
988 | 988 | ||
989 | static char *get_name(char *name, char *p) | 989 | char *get_name(char *name, char *p) |
990 | { | 990 | { |
991 | while (isspace(*p)) | 991 | /* Extract <name>[:<alias>] from nul-terminated p where p matches |
992 | p++; | 992 | <name>[:<alias>]: after leading whitespace. |
993 | while (*p) { | 993 | If match is not made, set name empty and return unchanged p */ |
994 | if (isspace(*p)) | 994 | int namestart=0, nameend=0, aliasend; |
995 | break; | 995 | while (isspace(p[namestart])) |
996 | if (*p == ':') { /* could be an alias */ | 996 | namestart++; |
997 | char *dot = p, *dotname = name; | 997 | nameend=namestart; |
998 | 998 | while (p[nameend] && p[nameend]!=':' && !isspace(p[nameend])) | |
999 | *name++ = *p++; | 999 | nameend++; |
1000 | while (isdigit(*p)) | 1000 | if (p[nameend]==':') { |
1001 | *name++ = *p++; | 1001 | aliasend=nameend+1; |
1002 | if (*p != ':') { /* it wasn't, backup */ | 1002 | while (p[aliasend] && isdigit(p[aliasend])) |
1003 | p = dot; | 1003 | aliasend++; |
1004 | name = dotname; | 1004 | if (p[aliasend]==':') { |
1005 | } | 1005 | nameend=aliasend; |
1006 | if (*p == '\0') | ||
1007 | return NULL; | ||
1008 | p++; | ||
1009 | break; | ||
1010 | } | 1006 | } |
1011 | *name++ = *p++; | 1007 | if ((nameend-namestart)<IFNAMSIZ) { |
1008 | memcpy(name,&p[namestart],nameend-namestart); | ||
1009 | name[nameend-namestart]='\0'; | ||
1010 | p=&p[nameend]; | ||
1011 | } else { | ||
1012 | /* Interface name too large */ | ||
1013 | name[0]='\0'; | ||
1014 | } | ||
1015 | } else { | ||
1016 | /* first ':' not found - return empty */ | ||
1017 | name[0]='\0'; | ||
1012 | } | 1018 | } |
1013 | *name++ = '\0'; | ||
1014 | return p; | 1019 | return p; |
1015 | } | 1020 | } |
1016 | 1021 | ||