Whamcloud - gitweb
LU-5383 utils: fix array index out of bounds
[fs/lustre-release.git] / 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] == '=') {