mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-05-11 09:48:24 +02:00
git-svn-id: http://svn.ipfire.org/svn/ipfire/IPFire/source@16 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
58
src/patches/net-tools-1.60-get_name.patch
Normal file
58
src/patches/net-tools-1.60-get_name.patch
Normal file
@@ -0,0 +1,58 @@
|
||||
diff -Nrup net-tools-1.60.orig/lib/interface.c net-tools-1.60/lib/interface.c
|
||||
--- net-tools-1.60.orig/lib/interface.c 2004-08-12 05:54:09.000000000 -0400
|
||||
+++ net-tools-1.60/lib/interface.c 2004-08-12 06:03:20.000000000 -0400
|
||||
@@ -203,28 +203,34 @@ out:
|
||||
|
||||
static char *get_name(char *name, char *p)
|
||||
{
|
||||
- while (isspace(*p))
|
||||
- p++;
|
||||
- while (*p) {
|
||||
- if (isspace(*p))
|
||||
- break;
|
||||
- if (*p == ':') { /* could be an alias */
|
||||
- char *dot = p, *dotname = name;
|
||||
- *name++ = *p++;
|
||||
- while (isdigit(*p))
|
||||
- *name++ = *p++;
|
||||
- if (*p != ':') { /* it wasn't, backup */
|
||||
- p = dot;
|
||||
- name = dotname;
|
||||
- }
|
||||
- if (*p == '\0')
|
||||
- return NULL;
|
||||
- p++;
|
||||
- break;
|
||||
+ /* Extract <name>[:<alias>] from nul-terminated p where p matches
|
||||
+ <name>[:<alias>]: after leading whitespace.
|
||||
+ If match is not made, set name empty and return unchanged p */
|
||||
+ int namestart=0, nameend=0, aliasend;
|
||||
+ while (isspace(p[namestart]))
|
||||
+ namestart++;
|
||||
+ nameend=namestart;
|
||||
+ while (p[nameend] && p[nameend]!=':' && !isspace(p[nameend]))
|
||||
+ nameend++;
|
||||
+ if (p[nameend]==':') {
|
||||
+ aliasend=nameend+1;
|
||||
+ while (p[aliasend] && isdigit(p[aliasend]))
|
||||
+ aliasend++;
|
||||
+ if (p[aliasend]==':') {
|
||||
+ nameend=aliasend;
|
||||
+ }
|
||||
+ if ((nameend-namestart)<IFNAMSIZ) {
|
||||
+ memcpy(name,&p[namestart],nameend-namestart);
|
||||
+ name[nameend-namestart]='\0';
|
||||
+ p=&p[nameend+1];
|
||||
+ } else {
|
||||
+ /* Interface name too large */
|
||||
+ name[0]='\0';
|
||||
}
|
||||
- *name++ = *p++;
|
||||
+ } else {
|
||||
+ /* first ':' not found - return empty */
|
||||
+ name[0]='\0';
|
||||
}
|
||||
- *name++ = '\0';
|
||||
return p;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user