summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-11-11 14:51:33 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-11 15:08:56 +0100
commit80485114ba34ff8390f489ad8cf7c66dc5d38fad (patch)
tree4e610195908a555f9597c1978243504d475d2e6e
parent96fb31bc01284147a34ab70c3e649af1576e8505 (diff)
downloadsubsurface-80485114ba34ff8390f489ad8cf7c66dc5d38fad.tar.gz
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 <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--profile.c2
1 files changed, 1 insertions, 1 deletions
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)