FTP: Allow 0-byte file sizes and harden size parsing#2243
Open
MegaManSec wants to merge 3 commits intosquid-cache:masterfrom
Open
FTP: Allow 0-byte file sizes and harden size parsing#2243MegaManSec wants to merge 3 commits intosquid-cache:masterfrom
MegaManSec wants to merge 3 commits intosquid-cache:masterfrom
Conversation
Interpret 213 SIZE as a decimal prefix. Parse leading digits and ignore trailing text. If missing digits, overflow, or negative, warn and mark size unknown (-1). Accept 0 to fix HEAD on empty files. Keep restart logic safe by not using REST when size is unknown.
This comment was marked as resolved.
This comment was marked as resolved.
yadij
requested changes
Sep 10, 2025
rousskov
requested changes
Sep 10, 2025
Contributor
rousskov
left a comment
There was a problem hiding this comment.
Current PR poorly duplicates complex httpHeaderParseOffset() code. I support improving this FTP size parser, but it is better to wait for my planned PR that implements high-quality reusable integer parser than to add one more complex variation that PR would have to deal with. I am labeling this PR accordingly.
yadij
approved these changes
Dec 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, we interpreted 213 SIZE by reading only the decimal
prefix, parsing leading digits and ignoring any trailing text and
accepted 0 to fix HEAD on empty files. If digits are missing, the value
overflows, or is negative, we warn and mark the size unknown (-1).