From 80485114ba34ff8390f489ad8cf7c66dc5d38fad Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 11 Nov 2012 14:51:33 +0100 Subject: Fix possible array bound violation for insanely long dives When we calculate the interval for the tick-marks for the dive, we need to limit 'i' to be within the size of the array. The code does that with a "i < 8" check, but the fact is, we must never increment past the last entry, which is 7 (the size of the array is 8, but the last valid index is 7). This only happens for unrealistically long dives. Which you can trigger either by inputting insane values for a manually created dive, or by merging two dives that are consecutive, but not close to each other time-wise (eg on different days ;) Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- profile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profile.c b/profile.c index c8ce440d6..700f5d08a 100644 --- a/profile.c +++ b/profile.c @@ -910,7 +910,7 @@ static void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi * we double the interval if this still doesn't get us to 12 or fewer * time markers */ i = 0; - while (maxtime / increments[i] > 12 && i < 8) + while (maxtime / increments[i] > 12 && i < 7) i++; incr = increments[i]; while (maxtime / incr > 12) -- cgit v1.2.3-70-g09d2