From b8bc3adfd943071bdab2ed186736f99d39397576 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 20 Jun 2012 14:03:14 +0200 Subject: get_mnt_opts: don't let empty option string cause (*mpt_optsp)[-1] reference This looks like a "can't happen" case (depending on what add_option does), so you may prefer to add an assertion instead. Change-Id: Ibfdd34fca045e5213de836cca252bd96408b2136 BUG: 789278 Signed-off-by: Jim Meyering Reviewed-on: http://review.gluster.com/3604 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- contrib/fuse-util/fusermount.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'contrib') diff --git a/contrib/fuse-util/fusermount.c b/contrib/fuse-util/fusermount.c index 9a8952571..4bd5bb61e 100644 --- a/contrib/fuse-util/fusermount.c +++ b/contrib/fuse-util/fusermount.c @@ -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(); -- cgit