Harden Cord append size accounting in MessageLite serialization (#26170)
Issue: total_size = size + output->size() could overflow on extreme input/state combinations.
Change: Introduced:
--output_size = output->size();
--guard: if (output_size > SIZE_MAX - size) { ... return false; }
--safe compute: const size_t total_size = size + output_size;
Security impact: Prevents integer-wraparound in serialization size accumulation, improving robustness against resource-exhaustion style inputs.
Closes #26170
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/26170 from nidu-ninja:message-lite-cord-size-overflow 7529d3c5af2473226caedc9a3fd6152dc432ae9e
PiperOrigin-RevId: 919303834 N
NiDU-NINJA committed
0e28fcf092c420008fa186dcced72e5a95cc8850
Parent: 0ffdd99
Committed by Copybara-Service <copybara-worker@google.com>
on 5/21/2026, 11:09:05 PM