ftp: make the MDTM date parser stricter (again)#21041
Closed
Conversation
A previous refactor made the parser more lenient and this takes it back to making sure only ascii digits are accepted. Added test 1684 to verify Follow-up to 304b518 Pointed out by Codex Security
Member
Author
|
This is not helpful... |
There was a problem hiding this comment.
Pull request overview
This PR tightens libcurl’s FTP MDTM (213) timestamp parsing to reject non-ASCII digits (addressing a regression toward leniency) and adds a regression test to ensure malformed MDTM dates no longer affect time-condition behavior.
Changes:
- Make the FTP 213 date parser require ASCII digits for each 2-digit field (instead of implicitly accepting other characters).
- Refactor the 2-digit parsing helper to return an error status and write the parsed value via an out-parameter.
- Add test1684 and register it in the test data Makefile to validate malformed MDTM handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/data/test1684 | Adds an FTP test case with a malformed MDTM timestamp to ensure stricter parsing and expected transfer behavior under -z. |
| tests/data/Makefile.am | Registers the new test1684 in the test list. |
| lib/ftp.c | Tightens MDTM “213” date parsing by validating digits with ISDIGIT() before converting fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
A previous refactor made the parser more lenient and this takes it back to making sure only ascii digits are accepted.
Added test 1684 to verify
Follow-up to 304b518
Pointed out by Codex Security