Whamcloud - gitweb
LU-14422 utils: check empty stripe-count/offset setting 93/41793/6
authorBobi Jam <bobijam@whamcloud.com>
Tue, 23 Mar 2021 03:18:25 +0000 (11:18 +0800)
committerOleg Drokin <green@whamcloud.com>
Sat, 11 Jun 2022 05:30:32 +0000 (05:30 +0000)
Prohibit "" stripe count and stripe offset setting in lfs setstripe.

Test-Parameters: trivial
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I4d0cc2354c4249a31222e0f90de39e16ec4694a5
Reviewed-on: https://review.whamcloud.com/41793
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/lfs.c

index e05f918..3a82712 100644 (file)
@@ -3670,7 +3670,7 @@ static int lfs_setstripe_internal(int argc, char **argv,
                case 'c':
                        errno = 0;
                        lsa.lsa_stripe_count = strtoul(optarg, &end, 0);
-                       if (errno != 0 || *end != '\0'||
+                       if (errno != 0 || *end != '\0'|| optarg == end ||
                            lsa.lsa_stripe_count < -1 ||
                            lsa.lsa_stripe_count > LOV_MAX_STRIPE_COUNT) {
                                fprintf(stderr,
@@ -3756,7 +3756,7 @@ static int lfs_setstripe_internal(int argc, char **argv,
                case 'i':
                        errno = 0;
                        lsa.lsa_stripe_off = strtol(optarg, &end, 0);
-                       if (errno != 0 || *end != '\0' ||
+                       if (errno != 0 || *end != '\0' || optarg == end ||
                            lsa.lsa_stripe_off < -1 ||
                            lsa.lsa_stripe_off > LOV_V1_INSANE_STRIPE_COUNT) {
                                fprintf(stderr,