aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-02 13:44:18 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-02 13:44:18 -0800
commitf88f8a98dffe05a0fefa1be43b099cdd7775c40b (patch)
treecb61f7626212e932df52116835461642d711fe13
parent10c440317aa744e72f180a348f924568f59c0a36 (diff)
downloadandroid_external_brctl-f88f8a98dffe05a0fefa1be43b099cdd7775c40b.tar.gz
android_external_brctl-f88f8a98dffe05a0fefa1be43b099cdd7775c40b.tar.bz2
android_external_brctl-f88f8a98dffe05a0fefa1be43b099cdd7775c40b.zip
Skip . and .. in foreach_bridge test
If bridge is name 'bridge' then the test for ./bridge would succeed and eventually cause a SEGV. Correct fix is to just skip . directories in scan.
-rw-r--r--libbridge/libbridge_init.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libbridge/libbridge_init.c b/libbridge/libbridge_init.c
index a7473bd..1c1acbd 100644
--- a/libbridge/libbridge_init.c
+++ b/libbridge/libbridge_init.c
@@ -49,7 +49,11 @@ static int isbridge(const struct dirent *entry)
char path[SYSFS_PATH_MAX];
struct stat st;
- snprintf(path, SYSFS_PATH_MAX, SYSFS_CLASS_NET "%s/bridge", entry->d_name);
+ if (entry->d_name[0] == '.')
+ return 0;
+
+ snprintf(path, SYSFS_PATH_MAX,
+ SYSFS_CLASS_NET "%s/bridge", entry->d_name);
return stat(path, &st) == 0 && S_ISDIR(st.st_mode);
}