-
Notifications
You must be signed in to change notification settings - Fork 599
FTP: More EPLF 'm' timestamp parsing fixes #2207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
yadij
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"good enough". Long-term we need to replace the parsing with a Tokenizer.
rousskov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eduard-bagdasaryan, please run this PR through the tests that you did for recent commit 965e255. I am a bit surprised that the reversal of that tmp condition has not affected those tests; I am not claiming that the official condition was correct.
Done, no problems were found. |
Co-authored-by: Alex Rousskov <[email protected]>
My primary concerns have been addressed.
|
I adjusted PR description a little to mention trailing garbage handling and to avoid retelling the fairly clear |
| if (*secondsEnd && *secondsEnd != ',') | ||
| break; // trailing garbage after the seconds value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alex: I wonder whether whitespace ought to be allowed after the
mNNNvalue.
Francesco: A quick reading of https://cr.yp.to/ftp/list/eplf.html says no, it ought not be allowed
Agreed. However, the same document also prohibits NUL after the mNNN value -- it requires a comma, even if m is the last fact in the list of facts. Thus, AFAICT, this code should become something like this:
| if (*secondsEnd && *secondsEnd != ',') | |
| break; // trailing garbage after the seconds value | |
| if (!secondsEnd || *secondsEnd != ',') | |
| break; // missing comma terminator after the `m` fact value |
Ideally, this check should be placed after seconds validation currently located below.
The
mcase in ftpListParseParts() reversed the strtol() validitycheck. We broke out when any digits were consumed instead of only when
no conversion happened. As a result, valid epoch timestamps were treated
as invalid and p->date was often left unset.
Also guard against ctime() returning nil and avoid null pointer
dereference if no newline is present in ctime() output.
Also reject
mentries with trailing garbage.