From 81b5a9eb443d88dff3d32a8c1c45fd94c077689c Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@stfc.ac.uk> Date: Thu, 31 Jul 2014 20:59:40 +0100 Subject: [PATCH] Fix buffer overrun in isis raw header access. Refs #9950 --- .../Framework/DataHandling/src/LoadISISNexus2.cpp | 11 +++++++---- .../Mantid/Framework/DataHandling/src/RawFileInfo.cpp | 4 +--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Code/Mantid/Framework/DataHandling/src/LoadISISNexus2.cpp b/Code/Mantid/Framework/DataHandling/src/LoadISISNexus2.cpp index 20027fcc25c..2a353dc165b 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadISISNexus2.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadISISNexus2.cpp @@ -732,10 +732,13 @@ namespace Mantid { size_t width = fieldWidths[i]; memcpy(destStart, srcStart, width*byte); - srcStart += width; - destStart += width; - memset(destStart, fieldSep, byte); // insert separator - destStart += 1; + if( i < 6 ) // no space after last field + { + srcStart += width; + destStart += width; + memset(destStart, fieldSep, byte); // insert separator + destStart += 1; + } } runDetails.addProperty("run_header", std::string(header, header + 86)); diff --git a/Code/Mantid/Framework/DataHandling/src/RawFileInfo.cpp b/Code/Mantid/Framework/DataHandling/src/RawFileInfo.cpp index 045ff2f781a..67113f58950 100644 --- a/Code/Mantid/Framework/DataHandling/src/RawFileInfo.cpp +++ b/Code/Mantid/Framework/DataHandling/src/RawFileInfo.cpp @@ -80,9 +80,7 @@ const std::string RawFileInfo::runHeader(const ISISRAW &isisRaw) start += 1; memcpy(start, rawHdr.hd_dur, 8*byte); - start += 8; - memset(start, fieldSep, byte); - start += 1; + // final field so no space afterward return std::string(header, header + 86); } -- GitLab