summaryrefslogtreecommitdiffstats
path: root/mount/mount.c
diff options
context:
space:
mode:
authorMike Frysinger2010-03-07 06:16:41 +0100
committerKarel Zak2010-03-11 10:23:00 +0100
commit96aad067caf63b06e3d4f83b945916501da19bcb (patch)
treeb1e0406597eccf9d44da979b7f1e6954a3f16d82 /mount/mount.c
parenttests: update fdisk tests (diff)
downloadkernel-qcow2-util-linux-96aad067caf63b06e3d4f83b945916501da19bcb.tar.gz
kernel-qcow2-util-linux-96aad067caf63b06e3d4f83b945916501da19bcb.tar.xz
kernel-qcow2-util-linux-96aad067caf63b06e3d4f83b945916501da19bcb.zip
mount: properly ignore comments in /etc/filesystems
The POSIX spec for sscanf() says that whitespace may be matched against 0 bytes which means doing sscanf(" %s") against "#foo" will result in a match. You can see this behavior by using the verbose options on a garbage file: ... mount: you didn't specify a filesystem type for /dev/null I will try all types mentioned in /etc/filesystems or /proc/filesystems Trying # mount: mount(2) syscall: source: "/dev/null", target: "/", filesystemtype: "#", mountflags: -1058209792, data: (null) Trying #vfat mount: mount(2) syscall: source: "/dev/null", target: "/", filesystemtype: "#vfat", mountflags: -1058209792, data: (null) ... Reported-by: Dave Barton <dave.barton@comodo.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'mount/mount.c')
-rw-r--r--mount/mount.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mount/mount.c b/mount/mount.c
index 0f1fc5a78..0f986df3b 100644
--- a/mount/mount.c
+++ b/mount/mount.c
@@ -782,8 +782,8 @@ procfsnext(FILE *procfs) {
char fsname[100];
while (fgets(line, sizeof(line), procfs)) {
- if (sscanf (line, "nodev %[^\n]\n", fsname) == 1) continue;
- if (sscanf (line, " %[^ \n]\n", fsname) != 1) continue;
+ if (sscanf (line, "nodev %[^#\n]\n", fsname) == 1) continue;
+ if (sscanf (line, " %[^# \n]\n", fsname) != 1) continue;
return xstrdup(fsname);
}
return 0;