aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Dilger <adilger@dilger.ca>2018-03-29 12:36:54 -0600
committerTheodore Ts'o <tytso@mit.edu>2018-03-29 23:01:19 -0400
commit17a1f2c1929630e3a79e6b98168d56f96acf2e8b (patch)
treebff3290114ffaadc58ef8ace60b014a5c1917e30
parent748924621fdd0e70a191091915fc9724d42e4796 (diff)
downloade2fsprogs-17a1f2c1929630e3a79e6b98168d56f96acf2e8b.tar.gz
filefrag: avoid temporary buffer overflow
If an unknown flag is present in a FIEMAP extent, it is printed as a hex value into a temporary buffer before adding it to the flags. If that unknown flag is over 0xfff then it will overflow the temporary buffer. Reported-by: Sarah Liu <wei3.liu@intel.com> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10335 Signed-off-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--misc/filefrag.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/misc/filefrag.c b/misc/filefrag.c
index 9c57ab930..dc003931b 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -179,7 +179,7 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
print_flag(&fe_flags, FIEMAP_EXTENT_SHARED, flags, "shared,");
/* print any unknown flags as hex values */
for (mask = 1; fe_flags != 0 && mask != 0; mask <<= 1) {
- char hex[6];
+ char hex[sizeof(mask) * 2 + 4]; /* 2 chars/byte + 0x, + NUL */
if ((fe_flags & mask) == 0)
continue;