From: Theodore Ts'o Date: Sun, 24 Jun 2018 04:39:37 +0000 (-0400) Subject: debugfs: avoid undefined bit shift in parse_uint() X-Git-Tag: v1.44.3-rc1~16 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=366d526f15ef06c0a832dee4abe2a0c0349adb92;p=tools%2Fe2fsprogs.git debugfs: avoid undefined bit shift in parse_uint() 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 --- diff --git a/debugfs/set_fields.c b/debugfs/set_fields.c index 117cfb8..6594906 100644 --- a/debugfs/set_fields.c +++ b/debugfs/set_fields.c @@ -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;