From: Zach Brown Date: Mon, 7 Oct 2013 21:43:03 +0000 (-0700) Subject: btrfs-progs: don't overflow colors[] in fragments X-Git-Tag: upstream/4.16.1~3072 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=29340e68532ede8fef3b0d84c8d4ae0f1b000d26;p=platform%2Fupstream%2Fbtrfs-progs.git btrfs-progs: don't overflow colors[] in fragments Stop iteration at the number of elements in the colors[] array when initializing the elements. Rather than a magic number. This was found by static analysis. Signed-off-by: Zach Brown Signed-off-by: David Sterba Signed-off-by: Chris Mason --- diff --git a/btrfs-fragments.c b/btrfs-fragments.c index 4dd94700..cedbc57a 100644 --- a/btrfs-fragments.c +++ b/btrfs-fragments.c @@ -283,7 +283,7 @@ list_fragments(int fd, u64 flags, char *dir) white = gdImageColorAllocate(im, 255, 255, 255); black = gdImageColorAllocate(im, 0, 0, 0); - for (j = 0; j < 10; ++j) + for (j = 0; j < ARRAY_SIZE(colors); ++j) colors[j] = black; init_colors(im, colors);