Skip to content

CTA frontend accepts files larger than a specified size

Summary

Integer overflow causes the CTA frontend to accept files that are larger than the size specified by the cta.archive_file.max_size_gb configuration variable.

Steps to reproduce

Set cta.archive_file.max_size_gb e.g.

[root@cta-frontend ~]# grep max_size /etc/cta/cta-frontend-xrootd.conf

cta.archivefile.max_size_gb 1000

Log and the current bug behaviour?

Jul 13 11:38:59 tpm102 cta-taped: LVL="ERROR" PID="37690" TID="38979" MSG="An error occurred for this file. End of migrations." thread="TapeWrite" tapeDrive="rz1-2,3,3" tapeVid="L08459" mountId="2" vo="afs" mediaType="LTO9" tapePool="afs-backup" logicalLibrary="ctaltolib-rz1-1" mountType="ArchiveForUser" vendor="IBM" capacityInBytes="18000000000000" fileId="4679652" fileSize="8682449680866" fSeq="1257" diskURL="root://dcache-desy66.desy.de:1091/0000C538AA4A76CC43ED835A0A57F90804FB" exceptionMessage="Failed ST write with crc32c in DriveGeneric::writeBlock Errno=5: Input/output error"

Cause

In FrontendService.cpp#L176

  // Initialise the Frontend
  auto archiveFileMaxSize = config.getOptionValueInt("cta.archivefile.max_size_gb");
  // Convert archiveFileMaxSize from GB to bytes
  m_archiveFileMaxSize = archiveFileMaxSize.has_value() ?  archiveFileMaxSize.value()*1024*1024*1024 : 0;

the results of archiveFileMaxSize.value()*1024*1024*1024 is implicitly treated as signed int type, which can be overflow.