From f9b76d9902542b4b342b4e7c4ffb43da56c37df2 Mon Sep 17 00:00:00 2001
From: Raquel Alvarez Banos <raquel.alvarez.banos@gmail.com>
Date: Fri, 22 May 2015 16:44:35 +0100
Subject: [PATCH] Re #11825 Check the number of bytes read

---
 Code/Mantid/Framework/Kernel/src/NexusDescriptor.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Code/Mantid/Framework/Kernel/src/NexusDescriptor.cpp b/Code/Mantid/Framework/Kernel/src/NexusDescriptor.cpp
index 39755715bc3..f05232f4cb5 100644
--- a/Code/Mantid/Framework/Kernel/src/NexusDescriptor.cpp
+++ b/Code/Mantid/Framework/Kernel/src/NexusDescriptor.cpp
@@ -50,8 +50,12 @@ bool isHDFHandle(FILE *fileHandle, NexusDescriptor::Version version) {
   // HDF4 check requires 4 bytes,  HDF5 check requires 8 bytes
   // Use same buffer and waste a few bytes if only checking HDF4
   unsigned char buffer[8] = {'0', '0', '0', '0', '0', '0', '0', '0'};
-  std::fread(static_cast<void *>(&buffer), sizeof(unsigned char),
-             NexusDescriptor::HDF5SignatureSize, fileHandle);
+  if (NexusDescriptor::HDF5SignatureSize !=
+      std::fread(static_cast<void *>(&buffer), sizeof(unsigned char),
+                 NexusDescriptor::HDF5SignatureSize, fileHandle)) {
+    throw std::runtime_error("Error while reading file");
+  }
+
   // Number of bytes read doesn't matter as if it is not enough then the memory
   // simply won't match
   // as the buffer has been "zeroed"
-- 
GitLab