From be50fca2564b2c03386d2e524c0cc65d93896602 Mon Sep 17 00:00:00 2001 From: tkuhr Date: Tue, 27 Jan 2004 10:12:39 +0000 Subject: [PATCH] extended check --- RAW/AliRawReader.h | 4 ++-- RAW/AliRawReaderDate.cxx | 22 +++++++++++++++++----- RAW/AliRawReaderRoot.cxx | 23 ++++++++++++++++++----- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/RAW/AliRawReader.h b/RAW/AliRawReader.h index 26667813bf1..3ba999969d8 100644 --- a/RAW/AliRawReader.h +++ b/RAW/AliRawReader.h @@ -39,8 +39,8 @@ class AliRawReader: public TObject { virtual Bool_t Reset() = 0; - enum {kErrMagic=1, kErrNoMiniHeader=2, kErrMiniMagic=3, - kErrSize=4, kErrOutOfBounds=5}; + enum {kErrMagic=1, kErrNoMiniHeader=2, kErrMiniMagic=4, + kErrSize=8, kErrOutOfBounds=16}; virtual Int_t CheckData() const; Int_t GetErrorCode() {return fErrorCode;}; diff --git a/RAW/AliRawReaderDate.cxx b/RAW/AliRawReaderDate.cxx index 235877ca67c..2769f744453 100644 --- a/RAW/AliRawReaderDate.cxx +++ b/RAW/AliRawReaderDate.cxx @@ -314,13 +314,14 @@ Int_t AliRawReaderDate::CheckData() const eventHeaderStruct* subEvent = NULL; UChar_t* position = 0; UChar_t* end = 0; + Int_t result = 0; while (kTRUE) { // get the first or the next sub event if at the end of a sub event if (!subEvent || (position >= end)) { // check for end of event data - if (position >= ((UChar_t*)fEvent)+fEvent->eventSize) return 0; + if (position >= ((UChar_t*)fEvent)+fEvent->eventSize) return result; if (subEvent) { subEvent = (eventHeaderStruct*) (((UChar_t*)subEvent) + subEvent->eventSize); @@ -330,7 +331,10 @@ Int_t AliRawReaderDate::CheckData() const } // check the magic word of the sub event - if (subEvent->eventMagic != EVENT_MAGIC_NUMBER) return kErrMagic; + if (subEvent->eventMagic != EVENT_MAGIC_NUMBER) { + result |= kErrMagic; + return result; + } position = ((UChar_t*)subEvent) + subEvent->eventHeadSize + sizeof(equipmentHeaderStruct); @@ -341,15 +345,23 @@ Int_t AliRawReaderDate::CheckData() const if (position >= end) continue; // check that there are enough bytes left for the mini header - if (position + sizeof(AliMiniHeader) > end) return kErrNoMiniHeader; + if (position + sizeof(AliMiniHeader) > end) { + result |= kErrNoMiniHeader; + position = end; + continue; + } // "read" and check the mini header AliMiniHeader* miniHeader = (AliMiniHeader*) position; position += sizeof(AliMiniHeader); - if (!CheckMiniHeader(miniHeader)) return kErrMiniMagic; + if (!CheckMiniHeader(miniHeader)){ + result |= kErrMiniMagic; + position = end; + continue; + } // check consistency of data size in the mini header and in the sub event - if (position + miniHeader->fSize > end) return kErrSize; + if (position + miniHeader->fSize > end) result |= kErrSize; position += miniHeader->fSize; }; diff --git a/RAW/AliRawReaderRoot.cxx b/RAW/AliRawReaderRoot.cxx index d5d921477f9..ec45eff76fc 100644 --- a/RAW/AliRawReaderRoot.cxx +++ b/RAW/AliRawReaderRoot.cxx @@ -32,6 +32,7 @@ AliRawReaderRoot::AliRawReaderRoot(const char* fileName, Int_t eventNumber) // create an object to read digits from the given input file for the // event with the given number + fEvent = NULL; TDirectory* dir = gDirectory; fFile = TFile::Open(fileName); dir->cd(); @@ -314,17 +315,21 @@ Int_t AliRawReaderRoot::CheckData() const Int_t subEventIndex = 0; UChar_t* position = 0; UChar_t* end = 0; + Int_t result = 0; while (kTRUE) { // get the first or the next sub event if at the end of a sub event if (!subEvent || (position >= end)) { // check for end of event data - if (subEventIndex >= fEvent->GetNSubEvents()) return 0; + if (subEventIndex >= fEvent->GetNSubEvents()) return result; subEvent = fEvent->GetSubEvent(subEventIndex++); // check the magic word of the sub event - if (!fSubEvent->GetHeader()->IsValid()) return kErrMagic; + if (!fSubEvent->GetHeader()->IsValid()) { + result |= kErrMagic; + return result; + } AliRawData* rawData = subEvent->GetRawData(); position = (UChar_t*) rawData->GetBuffer(); @@ -335,15 +340,23 @@ Int_t AliRawReaderRoot::CheckData() const if (position >= end) continue; // check that there are enough bytes left for the mini header - if (position + sizeof(AliMiniHeader) > end) return kErrNoMiniHeader; + if (position + sizeof(AliMiniHeader) > end) { + result |= kErrNoMiniHeader; + position = end; + continue; + } // "read" and check the mini header AliMiniHeader* miniHeader = (AliMiniHeader*) position; position += sizeof(AliMiniHeader); - if (!CheckMiniHeader(miniHeader)) return kErrMiniMagic; + if (!CheckMiniHeader(miniHeader)) { + result |= kErrMiniMagic; + position = end; + continue; + } // check consistency of data size in the mini header and in the sub event - if (position + miniHeader->fSize > end) return kErrSize; + if (position + miniHeader->fSize > end) result |= kErrSize; position += miniHeader->fSize; }; } -- 2.31.1