diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2005-11-18 21:02:36 +0000 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2005-11-18 21:02:36 +0000 |
commit | 832ee448ec543bcebcff391989963450c012dd80 (patch) | |
tree | 3dddf1848c71aafc5b21550ed7e87d4c34607d79 /util/fusermount.c | |
parent | 9c2ccb43c3cc960334e2ab0069501dc583c7dbf7 (diff) |
fix
Diffstat (limited to 'util/fusermount.c')
-rw-r--r-- | util/fusermount.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/util/fusermount.c b/util/fusermount.c index 742a25f..8d5562e 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -120,6 +120,23 @@ static void unlock_mtab(int mtablock) } } +/* Glibc addmntent() doesn't encode '\n', misencodes '\t' as '\n' + (version 2.3.2), and encodes '\\' differently as mount(8). So + let's not allow those characters, they are not all that usual in + filenames. */ +static int check_name(const char *name) +{ + char *s; + for (s = "\n\t\\"; *s; s++) { + if (strchr(name, *s)) { + fprintf(stderr, "%s: illegal character 0x%02x in mount entry\n", + progname, *s); + return -1; + } + } + return 0; +} + static int add_mount(const char *fsname, const char *mnt, const char *type, const char *opts) { @@ -128,6 +145,10 @@ static int add_mount(const char *fsname, const char *mnt, const char *type, struct mntent ent; FILE *fp; + if (check_name(fsname) == -1 || check_name(mnt) == -1 || + check_name(type) == -1 || check_name(opts) == -1) + return -1; + fp = setmntent(mtab, "a"); if (fp == NULL) { fprintf(stderr, "%s: failed to open %s: %s\n", progname, mtab, |