mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-05 20:55:46 +03:00
torture_session.c: Append a '\0' before string comparison
ssh_channel_read() reads the data into the buffer, but doesn't append a '\0' after it. When the buffer is asserted to be equal to a string further in the test, the assertion could fail if the byte after the data stored in the buffer doesn't contain '\0' (and it mayn't) This commit appends a '\0' after the data read into the buffer before comparing it with a string. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Sahana Prasad
parent
2df2324638
commit
19ced21adb
@@ -471,6 +471,8 @@ torture_channel_read_stderr(void **state)
|
|||||||
/* Everything in stderr */
|
/* Everything in stderr */
|
||||||
rc = ssh_channel_read(channel, buffer, sizeof(buffer), 1);
|
rc = ssh_channel_read(channel, buffer, sizeof(buffer), 1);
|
||||||
assert_int_equal(rc, strlen("ABCD"));
|
assert_int_equal(rc, strlen("ABCD"));
|
||||||
|
|
||||||
|
buffer[rc] = '\0';
|
||||||
assert_string_equal("ABCD", buffer);
|
assert_string_equal("ABCD", buffer);
|
||||||
|
|
||||||
ssh_channel_free(channel);
|
ssh_channel_free(channel);
|
||||||
|
Reference in New Issue
Block a user