From 23d177b31cdb0c357dc6b46f62cb592d2c069a09 Mon Sep 17 00:00:00 2001 From: Phil Olynyk Date: Thu, 30 Apr 2020 15:27:37 -0400 Subject: [PATCH] Add error checks to edf header values --- oscar/SleepLib/loader_plugins/edfparser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oscar/SleepLib/loader_plugins/edfparser.cpp b/oscar/SleepLib/loader_plugins/edfparser.cpp index 6d21fb9a..7a1b0452 100644 --- a/oscar/SleepLib/loader_plugins/edfparser.cpp +++ b/oscar/SleepLib/loader_plugins/edfparser.cpp @@ -134,7 +134,7 @@ bool EDFInfo::parseHeader( EDFHeaderRaw *hdrPtr ) } edfHdr.reserved44=QString::fromLatin1(hdrPtr->reserved, 44).trimmed(); edfHdr.num_data_records = QString::fromLatin1(hdrPtr->num_data_records, 8).toLong(&ok); - if (!ok) { + if ( (! ok) || (edfHdr.num_data_records < 1) ) { qWarning() << "EDFInfo::Parse() Bad data record count " << filename; // sleep(1); fileData.clear(); @@ -148,7 +148,7 @@ bool EDFInfo::parseHeader( EDFHeaderRaw *hdrPtr ) return false; } edfHdr.num_signals = QString::fromLatin1(hdrPtr->num_signals, 4).toLong(&ok); - if (!ok) { + if ( (! ok) || (edfHdr.num_signals < 1) || (edfHdr.num_signals > 256) ) { qWarning() << "EDFInfo::Parse() Bad number of signals " << filename; // sleep(1); fileData.clear();