Description: 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.
From: Andreas Dilger <adilger@dilger.ca>
Origin: upstream, commit:17a1f2c19296
---
 misc/filefrag.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
-- 
2.16.1.72.g5be1f00a9a

