diff --git a/Detectors/TOF/compression/include/TOFCompression/Compressor.h b/Detectors/TOF/compression/include/TOFCompression/Compressor.h index c807b5cfc0fe2..ede65acdccccc 100644 --- a/Detectors/TOF/compression/include/TOFCompression/Compressor.h +++ b/Detectors/TOF/compression/include/TOFCompression/Compressor.h @@ -40,6 +40,7 @@ class Compressor inline bool run() { rewind(); + mEncoderPointerMax = reinterpret_cast(mEncoderBuffer + mEncoderBufferSize); if (mDecoderCONET) { mDecoderPointerMax = reinterpret_cast(mDecoderBuffer + mDecoderBufferSize); while (mDecoderPointer < mDecoderPointerMax) { diff --git a/Detectors/TOF/compression/src/Compressor.cxx b/Detectors/TOF/compression/src/Compressor.cxx index 75f5fac714fb2..180d26cb7a6bf 100644 --- a/Detectors/TOF/compression/src/Compressor.cxx +++ b/Detectors/TOF/compression/src/Compressor.cxx @@ -209,6 +209,12 @@ bool Compressor::processHBF() } /** copy RDH open to encoder buffer **/ + + if (mEncoderPointer + mDecoderRDH->headerSize >= mEncoderPointerMax) { + LOG(error) << "link = " << rdh->feeId << ": beyond the buffer size mEncoderPointer+mDecoderRDH->headerSize = " << mEncoderPointer + mDecoderRDH->headerSize << " >= " + << "mEncoderPointerMax = " << mEncoderPointerMax; + return true; + } std::memcpy(mEncoderPointer, mDecoderRDH, mDecoderRDH->headerSize); mEncoderPointer = reinterpret_cast(reinterpret_cast(mEncoderPointer) + rdh->headerSize); @@ -246,6 +252,11 @@ bool Compressor::processHBF() /** copy RDH close to encoder buffer **/ /** CAREFUL WITH THE PAGE COUNTER **/ + if (mEncoderPointer + rdh->headerSize >= mEncoderPointerMax) { + LOG(error) << "link = " << rdh->feeId << ": beyond the buffer size mEncoderPointer+rdh->headerSize = " << mEncoderPointer + rdh->headerSize << " >= " + << "mEncoderPointerMax = " << mEncoderPointerMax; + return true; + } mEncoderRDH = reinterpret_cast(mEncoderPointer); std::memcpy(mEncoderRDH, rdh, rdh->headerSize); mEncoderRDH->memorySize = rdh->headerSize; diff --git a/Detectors/TOF/compression/src/tof-compressor.cxx b/Detectors/TOF/compression/src/tof-compressor.cxx index 604609e1080d6..4358ceae84bdb 100644 --- a/Detectors/TOF/compression/src/tof-compressor.cxx +++ b/Detectors/TOF/compression/src/tof-compressor.cxx @@ -135,7 +135,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) outputs, algoSpec, Options{ - {"tof-compressor-output-buffer-size", VariantType::Int, 0, {"Encoder output buffer size (in bytes). Zero = automatic (careful)."}}, + {"tof-compressor-output-buffer-size", VariantType::Int, 1048576, {"Encoder output buffer size (in bytes). Zero = automatic (careful)."}}, {"tof-compressor-conet-mode", VariantType::Bool, false, {"Decoder CONET flag"}}, {"tof-compressor-decoder-verbose", VariantType::Bool, false, {"Decoder verbose flag"}}, {"tof-compressor-encoder-verbose", VariantType::Bool, false, {"Encoder verbose flag"}},