Issue Task Resolved

#109741fix size calculation overflow for large inputs

TYPO3 GmbH TYPO3com 05/02/26, 07:12 updated 10/08/26, 10:05

Description

## Summary

Fix incorrect size calculation for large values in `GeneralUtility::getBytesFromSizeMeasurement()`.

—-

## Problem

Large inputs (e.g. `“1e20G”`) can overflow during float-based multiplication, producing incorrect integer results.

Example:

Input: `“1e20G”`
Before: `6396237370772946944` (incorrect)

—-

## Fix

Add a pre-multiplication overflow guard:

if ($bytes > intdiv(PHP_INT_MAX, MULTIPLIER)) {
return 0;
}

—-

## Impact

-No change for valid inputs
-Prevents incorrect values for extreme inputs

This issue was automatically created from https://github.com/TYPO3/typo3/pull/633

Reviews 2

History 26

  1. Gerrit Code Review pushed patch set 1 for main to change 93901 status New Under Review 05/02/26, 07:12

  2. Garvin Hicking changed Sprint Focus On Location Sprint 08/06/26, 15:57

  3. Gerrit Code Review pushed patch set 2 for main to change 93901 10/06/26, 15:48

  4. Gerrit Code Review pushed patch set 3 for main to change 93901 10/06/26, 15:50

  5. Gerrit Code Review pushed patch set 1 for 14.3 to change 96526 10/08/26, 10:00

  6. Anonymous commented and changed status Under Review Resolved done 0 % 100 % 10/08/26, 10:05

    Applied in changeset commit:8cad522c2bb97b8d389587d531d40de985f464e1.