From c06b0a3e248b4b49b3ffd3629be03058ef6356f7 Mon Sep 17 00:00:00 2001 From: Federico Montesino Pouzols <federico.montesino-pouzols@stfc.ac.uk> Date: Tue, 13 Oct 2015 17:11:52 +0100 Subject: [PATCH] check size from file used to allocate mem, 1075717, re #13951 --- Framework/DataHandling/src/LoadRaw/isisraw2.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Framework/DataHandling/src/LoadRaw/isisraw2.cpp b/Framework/DataHandling/src/LoadRaw/isisraw2.cpp index f4bbb1f4187..4029ea10496 100644 --- a/Framework/DataHandling/src/LoadRaw/isisraw2.cpp +++ b/Framework/DataHandling/src/LoadRaw/isisraw2.cpp @@ -95,7 +95,17 @@ int ISISRAW2::ioRAW(FILE *file, bool from_file, bool read_data) { // ISISRAW::ioRAW(file, &u_len, 1, from_file); if (from_file) { u_len = add.ad_data - add.ad_user - 2; + + if (u_len < 0 || (add.ad_data < add.ad_user + 2)) { + // this will/would be used for memory allocation + g_log.error() << "Error in u_len value read from file, it would be " + << u_len << "; where it is calculated as " + "u_len = ad_data - ad_user - 2, where ad_data: " + << add.ad_data << ", ad_user: " << add.ad_user << "\n"; + throw std::runtime_error("Inconsistent value for the field u_len found"); + } } + ISISRAW::ioRAW(file, &u_dat, u_len, from_file); ISISRAW::ioRAW(file, &ver8, 1, from_file); fgetpos(file, &dhdr_pos); -- GitLab