PG-2540 Fix buffer overread and simplify code for parsing comments#752
PG-2540 Fix buffer overread and simplify code for parsing comments#752jeltz wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #752 +/- ##
==========================================
- Coverage 88.33% 87.68% -0.65%
==========================================
Files 3 3
Lines 1329 1332 +3
Branches 201 202 +1
==========================================
- Hits 1174 1168 -6
- Misses 72 79 +7
- Partials 83 85 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dutow
left a comment
There was a problem hiding this comment.
There's also a possible over-read in this code. While the pr only aims for simplification, should we also fix that too, if we are already changing this area of code?
SELECT 1 /*tail*/ or SELECT 1 /*oops
inner while loop consumes */ and points to the null. End of foor loop increases pointer again. *q_iter used by the for loop is now the character after null.
The unterminated comment is similar, the while loop already ends with q_iter pointing to the null byte.
a21642c to
6f7faa4
Compare
|
@dutow Does this fix look correct for the over-read? |
6f7faa4 to
6fec9fd
Compare
dutow
left a comment
There was a problem hiding this comment.
Looks good now.
We should add more coverage to this (the cases I already mentioned for asan + maybe something like SELECT 1 /*a*//*b*/, but that can also be a separate PR.
|
Another question: since this now also includes a bugfix, it should have a proper ticket? |
|
Yeah, we probably should add a test case and a proper ticket now. |
After the end of a comment we skipped one extra byte ahead accidentally causing a potential buffer overread if that comment was at the very end and otherwise potentially missing a comment if we had two comments next to eachother.
The code was hard to read for no obvious gain so this attempts to make the code read more like one would expect. Also remove a redundant comment. Also fixes a potential off by one read.
6fec9fd to
97b3bb5
Compare
|
Pushed the bugfix as a separate commit with tests and added a reference to a bug in Jira. |
The code was hard to read for no obvious gain so this attempts to make the code read more like one would expect. Also remove a redundant comment.
PG-0