From f88f8a98dffe05a0fefa1be43b099cdd7775c40b Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 2 Mar 2009 13:44:18 -0800 Subject: 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. --- libbridge/libbridge_init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); } -- cgit v1.2.3