aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2004-07-23 01:49:46 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2004-07-23 01:49:46 +0000
commit2e99d43846d41970e67d2299f46aa4723ad37ea0 (patch)
treedb0cde853061213079a3ee68683233f4794820b0 /libbb
parent9c83e836281e75b9c4be3906d74d62f2f94a94ea (diff)
downloadbusybox-2e99d43846d41970e67d2299f46aa4723ad37ea0.tar.gz
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.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/interface.c31
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 @@
* that either displays or sets the characteristics of
* one or more of the system's networking interfaces.
*
- * Version: $Id: interface.c,v 1.22 2004/04/14 17:57:11 andersen Exp $
+ * Version: $Id: interface.c,v 1.23 2004/07/23 01:49:46 bug1 Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* and others. Copyright 1993 MicroWalt Corporation
@@ -889,30 +889,25 @@ static int sockets_open(int family)
}
/* like strcmp(), but knows about numbers */
-static int nstrcmp(const char *astr, const char *b)
+static int nstrcmp(const char *a, const char *b)
{
- const char *a = astr;
+ const char *a_ptr = a;
+ const char *b_ptr = b;
while (*a == *b) {
- if (*a == '\0')
+ if (*a == '\0') {
return 0;
+ }
+ if (!isdigit(*a) && isdigit(*(a+1))) {
+ a_ptr = a+1;
+ b_ptr = b+1;
+ }
a++;
b++;
}
- if (isdigit(*a)) {
- if (!isdigit(*b))
- return -1;
- while (a > astr) {
- a--;
- if (!isdigit(*a)) {
- a++;
- break;
- }
- if (!isdigit(*b))
- return -1;
- b--;
- }
- return atoi(a) > atoi(b) ? 1 : -1;
+
+ if (isdigit(*a) && isdigit(*b)) {
+ return atoi(a_ptr) > atoi(b_ptr) ? 1 : -1;
}
return *a - *b;
}