-
Notifications
You must be signed in to change notification settings - Fork 126
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
src: fix write after end of buffer #467
Merged
Merged
Conversation
This file contains 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
we hardcode `sock->buf[num_read] = '\0';` so num_read cannot be equal to the size of the buffer. Signed-off-by: Giuseppe Scrivano <[email protected]>
@haircommander PTAL |
LGTM |
/lgtm |
alexlarsson
added a commit
to alexlarsson/conmon
that referenced
this pull request
Dec 12, 2023
The change in commit 3605a36 broke the podman test/system tests: ``` ✗ [075] podman exec - cat from stdin (from function `bail-now' in file test/system/helpers.bash, line 227, from function `is' in file test/system/helpers.bash, line 956, in test file test/system/075-exec.bats, line 84) `is "${lines[0]}" "3000+0 records in" "dd: number of records in"' failed [11:10:24.237041104] $ /vcs/other/podman/bin/podman rm -t 0 --all --force --ignore [11:10:24.272179180] $ /vcs/other/podman/bin/podman ps --all --external --format {{.ID}} {{.Names}} [11:10:24.307984108] $ /vcs/other/podman/bin/podman images --all --format {{.Repository}}:{{.Tag}} {{.ID}} [11:10:24.339679735] quay.io/libpod/systemd-image:20230531 9984d4cfd1eb quay.io/libpod/testimage:20221018 f5a99120db64 [11:10:24.357682655] $ /vcs/other/podman/bin/podman run -d quay.io/libpod/testimage:20221018 top [11:10:24.499542609] 76f963b708fe74814e8e078bbc41af84368beafaad2da932dc4ee7c3d6629409 [11:10:24.512104004] $ /vcs/other/podman/bin/podman exec -i 76f963b708fe74814e8e078bbc41af84368beafaad2da932dc4ee7c3d6629409 cat [11:10:24.648299147] of9AOlHs62yCSNsgYav5 1500+0 records in 1500+0 records out 1536000 bytes (1,5 MB, 1,5 MiB) copied, 0,00696935 s, 220 MB/s [11:10:24.670650275] $ /vcs/other/podman/bin/podman exec -i 76f963b708fe74814e8e078bbc41af84368beafaad2da932dc4ee7c3d6629409 dd of=/tmp/bigfile bs=512 [11:10:24.768570699] 2999+1 records in 2999+1 records out #/vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv #| FAIL: dd: number of records in #| expected: '3000+0 records in' #| actual: '2999+1 records in' #\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` I'm not sure exactly why the socket buffer read size matters here, but changing it back to reading exactly 32k fixes the test again. To keep the fix from containers#467 I added an extra byte to the buffer. However, I wonder if that change was strictly needed, as the `sock->buf[num_read] = '\0'` code is only used for the notify case, which is not a streaming socket. Signed-off-by: Alexander Larsson <[email protected]>
Merged
alexlarsson
added a commit
to alexlarsson/conmon
that referenced
this pull request
Dec 12, 2023
The change in commit 3605a36 broke the podman test/system tests: ``` ✗ [075] podman exec - cat from stdin (from function `bail-now' in file test/system/helpers.bash, line 227, from function `is' in file test/system/helpers.bash, line 956, in test file test/system/075-exec.bats, line 84) `is "${lines[0]}" "3000+0 records in" "dd: number of records in"' failed [11:10:24.237041104] $ /vcs/other/podman/bin/podman rm -t 0 --all --force --ignore [11:10:24.272179180] $ /vcs/other/podman/bin/podman ps --all --external --format {{.ID}} {{.Names}} [11:10:24.307984108] $ /vcs/other/podman/bin/podman images --all --format {{.Repository}}:{{.Tag}} {{.ID}} [11:10:24.339679735] quay.io/libpod/systemd-image:20230531 9984d4cfd1eb quay.io/libpod/testimage:20221018 f5a99120db64 [11:10:24.357682655] $ /vcs/other/podman/bin/podman run -d quay.io/libpod/testimage:20221018 top [11:10:24.499542609] 76f963b708fe74814e8e078bbc41af84368beafaad2da932dc4ee7c3d6629409 [11:10:24.512104004] $ /vcs/other/podman/bin/podman exec -i 76f963b708fe74814e8e078bbc41af84368beafaad2da932dc4ee7c3d6629409 cat [11:10:24.648299147] of9AOlHs62yCSNsgYav5 1500+0 records in 1500+0 records out 1536000 bytes (1,5 MB, 1,5 MiB) copied, 0,00696935 s, 220 MB/s [11:10:24.670650275] $ /vcs/other/podman/bin/podman exec -i 76f963b708fe74814e8e078bbc41af84368beafaad2da932dc4ee7c3d6629409 dd of=/tmp/bigfile bs=512 [11:10:24.768570699] 2999+1 records in 2999+1 records out #/vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv #| FAIL: dd: number of records in #| expected: '3000+0 records in' #| actual: '2999+1 records in' #\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` I'm not sure exactly why the socket buffer read size matters here, but changing it back to reading exactly 32k fixes the test again. To keep the fix from containers#467 I added an extra byte to the buffer. However, I wonder if that change was strictly needed, as the `sock->buf[num_read] = '\0'` code is only used for the notify case, which is not a streaming socket. Signed-off-by: Alexander Larsson <[email protected]>
alexlarsson
added a commit
to alexlarsson/conmon
that referenced
this pull request
Dec 12, 2023
The change in commit 3605a36 broke the podman test/system tests: ``` ✗ [075] podman exec - cat from stdin (from function `bail-now' in file test/system/helpers.bash, line 227, from function `is' in file test/system/helpers.bash, line 956, in test file test/system/075-exec.bats, line 84) `is "${lines[0]}" "3000+0 records in" "dd: number of records in"' failed [11:10:24.237041104] $ /vcs/other/podman/bin/podman rm -t 0 --all --force --ignore [11:10:24.272179180] $ /vcs/other/podman/bin/podman ps --all --external --format {{.ID}} {{.Names}} [11:10:24.307984108] $ /vcs/other/podman/bin/podman images --all --format {{.Repository}}:{{.Tag}} {{.ID}} [11:10:24.339679735] quay.io/libpod/systemd-image:20230531 9984d4cfd1eb quay.io/libpod/testimage:20221018 f5a99120db64 [11:10:24.357682655] $ /vcs/other/podman/bin/podman run -d quay.io/libpod/testimage:20221018 top [11:10:24.499542609] 76f963b708fe74814e8e078bbc41af84368beafaad2da932dc4ee7c3d6629409 [11:10:24.512104004] $ /vcs/other/podman/bin/podman exec -i 76f963b708fe74814e8e078bbc41af84368beafaad2da932dc4ee7c3d6629409 cat [11:10:24.648299147] of9AOlHs62yCSNsgYav5 1500+0 records in 1500+0 records out 1536000 bytes (1,5 MB, 1,5 MiB) copied, 0,00696935 s, 220 MB/s [11:10:24.670650275] $ /vcs/other/podman/bin/podman exec -i 76f963b708fe74814e8e078bbc41af84368beafaad2da932dc4ee7c3d6629409 dd of=/tmp/bigfile bs=512 [11:10:24.768570699] 2999+1 records in 2999+1 records out #/vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv #| FAIL: dd: number of records in #| expected: '3000+0 records in' #| actual: '2999+1 records in' #\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` I'm not sure exactly why the socket buffer read size matters here, but changing it back to reading exactly 32k fixes the test again. To keep the fix from containers#467 I added an extra byte to the buffer. However, I wonder if that change was strictly needed, as the `sock->buf[num_read] = '\0'` code is only used for the notify case, which is not a streaming socket. Signed-off-by: Alexander Larsson <[email protected]>
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.
we hardcode
sock->buf[num_read] = '\0';
so num_read cannot be equal to the size of the buffer.