]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
added pointer consistency check before decoding
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Jul 2008 19:40:55 +0000 (19:40 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Jul 2008 19:40:55 +0000 (19:40 +0000)
RAW/AliAltroDecoder.cxx

index c885865d433e67cc923e9b1df54ad324f4b95e0c..cc757e1baf4aa40ec15984c006d7b4ebe0c73499 100644 (file)
@@ -102,7 +102,12 @@ Bool_t AliAltroDecoder::Decode()
       //     printf("\n AliAltroDecoder::Decode(). Please check on the return value (-1 if fataly corrupted) of the SetMemory() function\n");    
       return kFALSE;
     }
-
+  else if (!f8DtaPtr || !f32DtaPtr ||
+          (UChar_t*)f32DtaPtr < f8DtaPtr-fSize ||
+          (UChar_t*)f32DtaPtr > f8DtaPtr)
+    {
+      return kFALSE;
+    }
   else
     {
       // see header file for class documentation
@@ -375,7 +380,10 @@ int AliAltroDecoder::SetMemory(UChar_t *dtaPtr, UInt_t size)
       f32DtaPtr = (UInt_t *)dtaPtr + fkN32HeaderWords;
       fIsFatalCorruptedTrailer = kFALSE; 
     }
-  
+
+  // all subsequent consistency checks depend on the correct initialization
+  // of the pointer and size variables
+  assert(f8DtaPtr == dtaPtr + fSize);  
   return iRet;
 
 }