[PATCH 1/2] Fix seabear import sample overrun bug

Linus Torvalds torvalds at linux-foundation.org
Mon Apr 11 11:45:10 PDT 2016


From: Linus Torvalds <torvalds at linux-foundation.org>
Date: Mon, 11 Apr 2016 11:36:31 -0700
Subject: [PATCH] Fix seabear import sample overrun bug

The Seabear import fixed up the NDL and TTS in the samples from minutes
(in the import) to seconds (our internal format for all time).  But it
did it with a loop that overran the end of the samples array by one:

	for(int s_nr = 0 ; s_nr <= dive->dc.samples ; s_nr++) {

Fix it to use the proper "<" instead of "<=".

Reported-by: Stuart Vernon <stuartv at force2.net>
Tested-by: Miika Turkia <miika.turkia at gmail.com>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---

This is the one that applies to the stable branch 4.5.5. The stable 
branch as another buglet (which probably doesn't matter) that is already 
fixed in the development version, that is the 2/2 patch.

 qt-ui/divelogimportdialog.cpp | 2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 67faadf91614..26d38788c2b0 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -774,7 +774,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
 				}
 				// Seabear CSV stores NDL and TTS in Minutes, not seconds
 				struct dive *dive = dive_table.dives[dive_table.nr - 1];
-				for(int s_nr = 0 ; s_nr <= dive->dc.samples ; s_nr++) {
+				for(int s_nr = 0 ; s_nr < dive->dc.samples ; s_nr++) {
 					struct sample *sample = dive->dc.sample + s_nr;
 					sample->ndl.seconds *= 60;
 					sample->tts.seconds *= 60;


More information about the subsurface mailing list