diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2004-07-23 01:49:46 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2004-07-23 01:49:46 +0000 |
commit | 2e99d43846d41970e67d2299f46aa4723ad37ea0 (patch) | |
tree | db0cde853061213079a3ee68683233f4794820b0 | |
parent | 9c83e836281e75b9c4be3906d74d62f2f94a94ea (diff) | |
download | busybox-w32-2e99d43846d41970e67d2299f46aa4723ad37ea0.tar.gz busybox-w32-2e99d43846d41970e67d2299f46aa4723ad37ea0.tar.bz2 busybox-w32-2e99d43846d41970e67d2299f46aa4723ad37ea0.zip |
Fix for a bug identied by Harald Kuthe, when using many interfaces (29
in this case) the order was incorrect and there were duplicate entries.
-rw-r--r-- | libbb/interface.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/libbb/interface.c b/libbb/interface.c index 2589eec49..f3655b0e0 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.22 2004/04/14 17:57:11 andersen Exp $ | 18 | * Version: $Id: interface.c,v 1.23 2004/07/23 01:49:46 bug1 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 |
@@ -889,30 +889,25 @@ static int sockets_open(int family) | |||
889 | } | 889 | } |
890 | 890 | ||
891 | /* like strcmp(), but knows about numbers */ | 891 | /* like strcmp(), but knows about numbers */ |
892 | static int nstrcmp(const char *astr, const char *b) | 892 | static int nstrcmp(const char *a, const char *b) |
893 | { | 893 | { |
894 | const char *a = astr; | 894 | const char *a_ptr = a; |
895 | const char *b_ptr = b; | ||
895 | 896 | ||
896 | while (*a == *b) { | 897 | while (*a == *b) { |
897 | if (*a == '\0') | 898 | if (*a == '\0') { |
898 | return 0; | 899 | return 0; |
900 | } | ||
901 | if (!isdigit(*a) && isdigit(*(a+1))) { | ||
902 | a_ptr = a+1; | ||
903 | b_ptr = b+1; | ||
904 | } | ||
899 | a++; | 905 | a++; |
900 | b++; | 906 | b++; |
901 | } | 907 | } |
902 | if (isdigit(*a)) { | 908 | |
903 | if (!isdigit(*b)) | 909 | if (isdigit(*a) && isdigit(*b)) { |
904 | return -1; | 910 | return atoi(a_ptr) > atoi(b_ptr) ? 1 : -1; |
905 | while (a > astr) { | ||
906 | a--; | ||
907 | if (!isdigit(*a)) { | ||
908 | a++; | ||
909 | break; | ||
910 | } | ||
911 | if (!isdigit(*b)) | ||
912 | return -1; | ||
913 | b--; | ||
914 | } | ||
915 | return atoi(a) > atoi(b) ? 1 : -1; | ||
916 | } | 911 | } |
917 | return *a - *b; | 912 | return *a - *b; |
918 | } | 913 | } |