Whamcloud - gitweb
LU-16152 utils: fix integer overflow in cYAML parser 49/48649/7
authorLei Feng <flei@whamcloud.com>
Mon, 26 Sep 2022 06:31:57 +0000 (14:31 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Nov 2022 08:50:26 +0000 (08:50 +0000)
Convert double to int64 correctly in cYAML parser.

Signed-off-by: Lei Feng <flei@whamcloud.com>
Test-Parameters: trivial testlist=sanity env=ONLY=65p
Change-Id: Ia3fd515c76ebfe6e5181301f53c702ef82056eba
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48649
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Emoly Liu <emoly@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/utils/lnetconfig/cyaml.c
lustre/tests/sanity.sh

index 0c859a1..7c82645 100644 (file)
@@ -391,7 +391,7 @@ static bool parse_number(struct cYAML *item, const char *input)
        n = sign * n * pow(10.0, (scale + subscale * signsubscale));
 
        item->cy_valuedouble = n;
-       item->cy_valueint = (int)n;
+       item->cy_valueint = (int64_t)n;
        item->cy_type = CYAML_TYPE_NUMBER;
 
        return true;
index f90d408..11a3442 100755 (executable)
@@ -9667,6 +9667,34 @@ test_65o() {
 }
 run_test 65o "pool inheritance for mdt component"
 
+test_65p () { # LU-16152
+       local src_dir=$DIR/$tdir/src_dir
+       local dst_dir=$DIR/$tdir/dst_dir
+       local yaml_file=$DIR/$tdir/layout.yaml
+       local border
+
+       (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
+               skip "Need at least version 2.15.51"
+
+       test_mkdir -p $src_dir
+       $LFS setstripe -E 2048M -c 4 -E EOF -c 8 $src_dir ||
+               error "failed to setstripe"
+       $LFS getstripe --yaml -d $src_dir > $yaml_file ||
+               error "failed to getstripe"
+
+       test_mkdir -p $dst_dir
+       $LFS setstripe --yaml $yaml_file $dst_dir ||
+               error "failed to setstripe with yaml file"
+       border=$($LFS getstripe -d $dst_dir |
+               awk '/lcme_extent.e_end:/ { print $2; exit; }') ||
+               error "failed to getstripe"
+
+       # 2048M is 0x80000000, or 2147483648
+       (( $border == 2147483648 )) ||
+               error "failed to handle huge number in yaml layout"
+}
+run_test 65p "setstripe with yaml file and huge number"
+
 # bug 2543 - update blocks count on client
 test_66() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run"