diff options
Diffstat (limited to 'contrib/fuse-util/fusermount.c')
| -rw-r--r-- | contrib/fuse-util/fusermount.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/contrib/fuse-util/fusermount.c b/contrib/fuse-util/fusermount.c index 9a8952571..0ff8d9039 100644 --- a/contrib/fuse-util/fusermount.c +++ b/contrib/fuse-util/fusermount.c @@ -505,13 +505,13 @@ static void read_conf(void) int isnewline = 1; while (fgets(line, sizeof(line), fp) != NULL) { if (isnewline) { - if (line[strlen(line)-1] == '\n') { + if (strlen(line) && line[strlen(line)-1] == '\n') { strip_line(line); parse_line(line, linenum); } else { isnewline = 0; } - } else if(line[strlen(line)-1] == '\n') { + } else if(strlen(line) && line[strlen(line)-1] == '\n') { fprintf(stderr, "%s: reading %s: line %i too long\n", progname, FUSE_CONF, linenum); isnewline = 1; @@ -606,7 +606,7 @@ static int add_option(char **optsp, const char *opt, unsigned expand) static int get_mnt_opts(int flags, char *opts, char **mnt_optsp) { int i; - int l; + size_t l; if (!(flags & MS_RDONLY) && add_option(mnt_optsp, "rw", 0) == -1) return -1; @@ -621,7 +621,7 @@ static int get_mnt_opts(int flags, char *opts, char **mnt_optsp) return -1; /* remove comma from end of opts*/ l = strlen(*mnt_optsp); - if ((*mnt_optsp)[l-1] == ',') + if (l && (*mnt_optsp)[l-1] == ',') (*mnt_optsp)[l-1] = '\0'; if (getuid() != 0) { const char *user = get_user_name(); @@ -650,8 +650,7 @@ static int get_string_opt(const char *s, unsigned len, const char *opt, unsigned opt_len = strlen(opt); char *d; - if (*val) - free(*val); + free(*val); *val = (char *) malloc(len - opt_len + 1); if (!*val) { fprintf(stderr, "%s: failed to allocate memory\n", progname); |
