Repository navigation
Conversation
rotctld_socket_rw() let recv() fill the whole buffer and then wrote the terminating NUL at buffout[size], one byte past the end of the 128-byte buffers used by get_pos(), set_pos() and rot_locked_cb() when the reply was 128 bytes or longer. Read at most sizeout - 1 bytes, as the rigctld helper in gtk-rig-ctrl.c already does. Fixes csete#435
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.
rotctld_socket_rw()passed the full buffer size torecv()and then wrote the terminating NUL atbuffout[size]. All three callers (get_pos(),set_pos(),rot_locked_cb()) use 128-byte buffers, so a reply of 128 bytes or more wrote one byte past the end of the stack array.This reads at most
sizeout - 1bytes, the same as the rigctld helper ingtk-rig-ctrl.c. Normal rotctld replies are far shorter than that, so nothing changes for them.Tested with an AddressSanitizer harness that runs the function against a socketpair peer: on master, 128- and 200-byte replies trigger a stack-buffer-overflow; with the fix, all reply sizes (20, 127, 128, 200) are handled cleanly. Full build and
make checkpass with no new warnings.Fixes #435