Whamcloud - gitweb
LU-5383 utils: fix array index out of bounds 24/12524/2
authorDmitry Eremin <dmitry.eremin@intel.com>
Fri, 31 Oct 2014 15:33:59 +0000 (18:33 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 4 Nov 2014 18:15:18 +0000 (18:15 +0000)
Possible attempt to access element -8..-1 of array 'ldd_svname'.

Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Change-Id: Ib4ec6a6d74ff6e805725d0ff4487868b7cbffa2f
Reviewed-on: http://review.whamcloud.com/12524
Tested-by: Jenkins
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/mount_lustre.c

index 8e9b00a..d32c77a 100644 (file)
@@ -422,7 +422,11 @@ static int parse_ldd(char *source, struct mount_opts *mop, char *options)
 
        /* svname of the form lustre:OST1234 means never registered */
        rc = strlen(ldd->ldd_svname);
-       if (ldd->ldd_svname[rc - 8] == ':') {
+       if (rc < 8) {
+               fprintf(stderr, "%s: invalid name '%s'\n",
+                       progname, ldd->ldd_svname);
+               return EINVAL;
+       } else if (ldd->ldd_svname[rc - 8] == ':') {
                ldd->ldd_svname[rc - 8] = '-';
                ldd->ldd_flags |= LDD_F_VIRGIN;
        } else if (ldd->ldd_svname[rc - 8] == '=') {