-
Notifications
You must be signed in to change notification settings - Fork 55
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
Normalize EOL to CRLF for text-mode signatures. #1263
Conversation
a04edbd
to
74e393c
Compare
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.
LGTM @ni4 !
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.
In my case, test_stream_signatures
fails because src/tests/data/test_stream_signatures/source.txt
received extra CR when cloning from github without git config --global core.autocrlf false
.
Shouldn't we update test files in this PR so they no longer depend on github settings?
Actually, some signatures there are done in binary mode, so tests will actually fail if eol sequence is changed in source.txt |
@ni4 The question is -- the test will remain dependent on git settings? |
@rrrooommmaaa Please see the issue #1268 And, getting back to review, do you have any further comments/suggestions on this PR? |
@ni4 I expect that |
@rrrooommmaaa Once CR character is reached, CRLF is written. I.e. the only purpose of this flag - to detect case where CR is the last character in buffer, and the possible following LF is sent in the next |
got it now. Can you add a remark in the code describing the purpose of |
74e393c
to
78923d1
Compare
Added comment and force-pushed.
Just got used to this style, to use 2 chars for temporary variable name, where i,j,k are not applicable. |
I'd vote against this style personally. I like names to be as descriptive as possible, just not overly long. |
Ok, np. While it is clear how to rename |
I would read I may be biased specifically on EDIT: |
78923d1
to
4342adf
Compare
@dewyatt Thanks for the detailed explanation. Renamed/force-pushed. |
@ni4 As long as |
@rrrooommmaaa Please see the updated PR. Actually it is simpler then input_from_callback since we know that information for signed_src_update() is read by 32k chunks. |
ch++; | ||
} | ||
uint8_t *linebeg = ch; | ||
uint8_t *end = (uint8_t *) buf + len; |
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.
This piece of code will work in 99.9999% cases, I understand, still, it doesn't look clean, as in theory the buffer might be at the very end of virtual memory, so buf+len
can be 0x00000
or an overflow exception can be thrown,
so ch<end
and ch<end+1
may be false right away.
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.
@rrrooommmaaa Thanks for pointing at this. While it should not happen in real-life systems, this may be hit on low-memory embedded systems or so on. Added a commit.
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.
I suggest simply to replace ch < end
and ch + 1 < end
with !=
I know that <
is generally safer than !=
but in this case it would be neater
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.
@rrrooommmaaa That was the first idea, however then we would end up in need to check whether ch++ overflows, adding one more check on each byte processed.
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.
Ok, merging then.
b45c9df
to
3fb08a9
Compare
I vote for |
ch++; | ||
} | ||
uint8_t *linebeg = ch; | ||
uint8_t *end = (uint8_t *) buf + len; |
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.
I suggest simply to replace ch < end
and ch + 1 < end
with !=
I know that <
is generally safer than !=
but in this case it would be neater
Previously we didn't distinguish text-mode document signatures from binary ones, so for non-canonical line endings (i.e. non-CRLF) validation failed.
This PR is aimed to fix this misbehavior.
Fixes #1226
Closes #1228