Conversation
Also use vim_strncpy
Member
|
I am not sure I understand. Technically those two statements do exactly the same: -if (strlen(tok) + i < KEYBUFLEN)
+if (strlen(tok) + i + 1 <= KEYBUFLEN)I think the vim_strncpy() is an improvement however. |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a remaining off-by-one buffer overflow risk in Vim’s NetBeans integration when building keybuf for specialKeys mappings, ensuring space for the terminating NUL byte.
Changes:
- Adjusts the length check to account for the required NUL terminator (
+ 1). - Replaces
strcpy()withvim_strncpy()to enforce bounded copying intokeybuf.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
Author
|
Ooops, Sorry. It seems I must have been asleep... |
Member
|
Well, do you think we should include the |
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.
@chrisbra I suspect this fix does not fully resolve the issue.
c5f312a#diff-012c27cfc933c3fb6030c48e84f44e5cd2706af0b1ac94631f6a5d31b13170b0R2322
keybuf[KEYBUFLEN]is a fixed-size buffer of 64 bytes (KEYBUFLEN = 64)strlen(tok)returns the string length (NUL terminator not included)iis the number of characters already written to keybufAfter copying, we need 1 additional byte for the NUL terminator (
\0). And the original checkstrlen(tok) + i < 64only checked up to 63 bytes.