@@ -53,8 +53,8 @@ using namespace edm::streamer;
5353FedRawDataInputSource::FedRawDataInputSource (edm::ParameterSet const & pset, edm::InputSourceDescription const & desc)
5454 : edm::RawInputSource(pset, desc),
5555 defPath_(pset.getUntrackedParameter<std::string>(" buDefPath" , " " )),
56- eventChunkSize_ (pset.getUntrackedParameter<unsigned int >(" eventChunkSize" , 32 ) * 1048576 ),
57- eventChunkBlock_ (pset.getUntrackedParameter<unsigned int >(" eventChunkBlock" , 32 ) * 1048576 ),
56+ paramChunkSize_ (pset.getUntrackedParameter<unsigned int >(" eventChunkSize" , 32 )),
57+ paramBlockSize_ (pset.getUntrackedParameter<unsigned int >(" eventChunkBlock" , 32 )),
5858 numConcurrentReads_(pset.getUntrackedParameter<int >(" numConcurrentReads" , -1 )),
5959 numBuffers_(pset.getUntrackedParameter<unsigned int >(" numBuffers" , 2 )),
6060 maxBufferedFiles_(pset.getUntrackedParameter<unsigned int >(" maxBufferedFiles" , 2 )),
@@ -77,6 +77,17 @@ FedRawDataInputSource::FedRawDataInputSource(edm::ParameterSet const& pset, edm:
7777 eventsThisLumi_(0 ) {
7878 char thishost[256 ];
7979 gethostname (thishost, 255 );
80+
81+ // ensure 32-bit buffer limits
82+ if (paramChunkSize_ > 4095 )
83+ throw cms::Exception (" FedRawDataInputSource::fillFEDRawDataCollection" )
84+ << " Invalid chunk size of " << paramChunkSize_ << " MB. Only less than 4GB is supported." ;
85+ if (paramBlockSize_ > 4095 )
86+ throw cms::Exception (" FedRawDataInputSource::fillFEDRawDataCollection" )
87+ << " Invalid block size of " << paramBlockSize_ << " MB. Only less than 4GB is supported." ;
88+ eventChunkSize_ = paramChunkSize_ << 20 ;
89+ eventChunkBlock_ = paramBlockSize_ << 20 ;
90+
8091 edm::LogInfo (" FedRawDataInputSource" ) << " Construction. read-ahead chunk size -: " << std::endl
8192 << (eventChunkSize_ / 1048576 ) << " MB on host " << thishost;
8293
@@ -476,6 +487,13 @@ inline evf::EvFDaqDirector::FileStatus FedRawDataInputSource::getNextEvent() {
476487 // advance buffer position to skip file header (chunk will be acquired later)
477488 currentFile_->chunkPosition_ += currentFile_->rawHeaderSize_ ;
478489 currentFile_->bufferPosition_ += currentFile_->rawHeaderSize_ ;
490+
491+ if (currentFile_->chunkPosition_ > UINT32_MAX)
492+ throw cms::Exception (" FedRawDataInputSource::getNextEvent" )
493+ << " chunkPosition_ overflow " << currentFile_->chunkPosition_ ;
494+ if (currentFile_->bufferPosition_ > UINT32_MAX)
495+ throw cms::Exception (" FedRawDataInputSource::getNextEvent" )
496+ << " bufferPosition_ overflow " << currentFile_->bufferPosition_ ;
479497 }
480498
481499 // file is too short
@@ -532,7 +550,12 @@ inline evf::EvFDaqDirector::FileStatus FedRawDataInputSource::getNextEvent() {
532550 chunkIsFree_ = true ;
533551 } else {
534552 // header was contiguous, but check if payload fits the chunk
535- if (eventChunkSize_ - currentFile_->chunkPosition_ < msgSize) {
553+
554+ if (currentFile_->chunkPosition_ > UINT32_MAX)
555+ throw cms::Exception (" FedRawDataInputSource::getNextEvent" )
556+ << " chunkPosition_ overflow " << currentFile_->chunkPosition_ ;
557+
558+ if (eventChunkSize_ - (uint32_t )currentFile_->chunkPosition_ < msgSize) {
536559 // rewind to header start position
537560 currentFile_->rewindChunk (FRDHeaderVersionSize[detectedFRDversion_]);
538561 // copy event to a chunk start and move pointers
@@ -1528,12 +1551,17 @@ void FedRawDataInputSource::readNextChunkIntoBuffer(InputFile* file) {
15281551 }
15291552 } else {
15301553 // event didn't fit in last chunk, so leftover must be moved to the beginning and completed
1531- uint32_t existingSizeLeft = eventChunkSize_ - file->chunkPosition_ ;
1554+
1555+ if (file->chunkPosition_ > UINT32_MAX)
1556+ throw cms::Exception (" FedRawDataInputSource::readNextChunkIntoBuffer" )
1557+ << " chunkPosition_ overflow " << file->chunkPosition_ ;
1558+
1559+ uint32_t existingSizeLeft = eventChunkSize_ - (uint32_t )file->chunkPosition_ ;
15321560 memmove ((void *)file->chunks_ [0 ]->buf_ , file->chunks_ [0 ]->buf_ + file->chunkPosition_ , existingSizeLeft);
15331561
15341562 // calculate amount of data that can be added
1535- const uint32_t blockcount = file->chunkPosition_ / eventChunkBlock_;
1536- const uint32_t leftsize = file->chunkPosition_ % eventChunkBlock_;
1563+ const uint32_t blockcount = ( uint32_t ) file->chunkPosition_ / eventChunkBlock_;
1564+ const uint32_t leftsize = ( uint32_t ) file->chunkPosition_ % eventChunkBlock_;
15371565
15381566 for (uint32_t i = 0 ; i < blockcount; i++) {
15391567 const ssize_t last =
0 commit comments