Fix core dump when tags file pattern has a trailing '\' #111
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.
... due to
size_tbeing unsigned and a loop that checks for > 0 which is always true (even when the loop variable is decremented twice).I found that I could crash nvi (both the @lichray fork and the version that comes with the base 13.1-RELEASE system) with a tags file for this macro:
I believe the trigger is the trailing '\'. The crash happens in a loop in re_tag_conv():
The extra
--lenwhen len is already zero is the problem.It's possible
size_twas signed on the system nvi was developed. But at least one source claimssize_tis "always unsigned".This PR only addresses the crash I could reproduce by making len an
int(large enough for lines in a tags file). But there are more than 100 places where len is declared asize_tand many/most of them have loops with len > 0 as the condition. The simple fix for the rest of these would be to changesize_ttoint.Another way to address this would be to look for places where the loop variable is a
size_tand the loop variable is decremented inside the loop. But that seems fragile.