]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
debugfs: avoid undefined bit shift in parse_uint()
authorTheodore Ts'o <tytso@mit.edu>
Sun, 24 Jun 2018 04:39:37 +0000 (00:39 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 24 Jun 2018 04:39:37 +0000 (00:39 -0400)
The case is one that should never happen (and indicates a bug if it
does), but in that case, we should still avoid an undefiniced C
expression.

Fixes-Coverity-Bug: 1297494
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/set_fields.c

index 117cfb81d8e681cd0bbb7d1391b690c83ea68bc9..65949060d980feb060278a58d5fa2b3407a76a69 100644 (file)
@@ -495,7 +495,7 @@ static errcode_t parse_uint(struct field_set_info *info, char *field,
        }
        if (!field2)
                return 0;
-       n = num >> (size*8);
+       n = (size == 8) ? 0 : (num >> (size*8));
        u.ptr8 = (__u8 *) field2;
        if (info->size == 6)
                size = 2;