From 19ced21adb4596ee1102aad592e48a04e59ad7bd Mon Sep 17 00:00:00 2001 From: Eshan Kelkar Date: Tue, 21 Nov 2023 19:47:33 +0530 Subject: [PATCH] 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 Reviewed-by: Sahana Prasad Reviewed-by: Jakub Jelen --- tests/client/torture_session.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/client/torture_session.c b/tests/client/torture_session.c index 37ed573a..d10b328d 100644 --- a/tests/client/torture_session.c +++ b/tests/client/torture_session.c @@ -471,6 +471,8 @@ torture_channel_read_stderr(void **state) /* Everything in stderr */ rc = ssh_channel_read(channel, buffer, sizeof(buffer), 1); assert_int_equal(rc, strlen("ABCD")); + + buffer[rc] = '\0'; assert_string_equal("ABCD", buffer); ssh_channel_free(channel);