summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZach Brown <zab@redhat.com>2013-10-07 14:43:03 -0700
committerChris Mason <chris.mason@fusionio.com>2013-10-16 08:23:13 -0400
commit29340e68532ede8fef3b0d84c8d4ae0f1b000d26 (patch)
tree2be898b543b76cdc7aeefe983161b552c7384fd0
parente2da6395959c454d1e98ff03b259ddc7e96b5861 (diff)
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 <zab@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--btrfs-fragments.c2
1 files changed, 1 insertions, 1 deletions
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);