From cab8b0cddaabd4d08f30cae8c507d362040645c7 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Fri, 31 Oct 2014 18:33:59 +0300 Subject: [PATCH] LU-5383 utils: fix array index out of bounds Possible attempt to access element -8..-1 of array 'ldd_svname'. Signed-off-by: Dmitry Eremin Change-Id: Ib4ec6a6d74ff6e805725d0ff4487868b7cbffa2f Reviewed-on: http://review.whamcloud.com/12524 Tested-by: Jenkins Reviewed-by: James Simmons Reviewed-by: Bob Glossman Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/utils/mount_lustre.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c index 8e9b00a..d32c77a 100644 --- a/lustre/utils/mount_lustre.c +++ b/lustre/utils/mount_lustre.c @@ -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] == '=') { -- 1.8.3.1