summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-06-20 14:03:14 +0200
committerAnand Avati <avati@redhat.com>2012-07-02 15:58:33 -0700
commitb8bc3adfd943071bdab2ed186736f99d39397576 (patch)
tree375ec7c2c6e2695f0272880fdde7ded1d4085c61
parent004d01ddfa6b9388835bb05a3b13a766719e2158 (diff)
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 <meyering@redhat.com> Reviewed-on: http://review.gluster.com/3604 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--contrib/fuse-util/fusermount.c4
1 files changed, 2 insertions, 2 deletions
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();