[PATCH v2 0/1] MR5203: webservices/tests: Fix -Warray-bounds warning on gcc 13.2.0.
-- v2: webservices/tests: Fix -Warray-bounds warning on gcc 13.2.0. https://gitlab.winehq.org/wine/wine/-/merge_requests/5203
From: Connor McAdams <cmcadams(a)codeweavers.com> Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/webservices/tests/channel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/webservices/tests/channel.c b/dlls/webservices/tests/channel.c index 4cf39c10732..1124672f6d5 100644 --- a/dlls/webservices/tests/channel.c +++ b/dlls/webservices/tests/channel.c @@ -1220,9 +1220,9 @@ static BOOL send_dict_str( int sock, char *addr, const char *str, int dict_str_c int offset, dict_buf_size, body_buf_size, dict_size; /* Session dictionary strings. */ - offset = write_size( dict_buf, strlen(str) ); - memcpy( dict_buf + offset, str, strlen(str) ); - dict_buf_size = strlen(str) + offset; + offset = write_size( dict_buf, strnlen(str, ARRAY_SIZE(dict_buf) - ARRAY_SIZE(dict_size_buf))); + memcpy( dict_buf + offset, str, strnlen(str, ARRAY_SIZE(dict_buf) - ARRAY_SIZE(dict_size_buf)) ); + dict_buf_size = strnlen(str, ARRAY_SIZE(dict_buf) - ARRAY_SIZE(dict_size_buf)) + offset; dict_size = write_size( dict_size_buf, dict_buf_size ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5203
Hans Leidekker (@hans) commented about dlls/webservices/tests/channel.c:
int offset, dict_buf_size, body_buf_size, dict_size;
/* Session dictionary strings. */ - offset = write_size( dict_buf, strlen(str) ); - memcpy( dict_buf + offset, str, strlen(str) ); - dict_buf_size = strlen(str) + offset; + offset = write_size( dict_buf, strnlen(str, ARRAY_SIZE(dict_buf) - ARRAY_SIZE(dict_size_buf))); + memcpy( dict_buf + offset, str, strnlen(str, ARRAY_SIZE(dict_buf) - ARRAY_SIZE(dict_size_buf)) ); + dict_buf_size = strnlen(str, ARRAY_SIZE(dict_buf) - ARRAY_SIZE(dict_size_buf)) + offset;
Looks good, but a 'max_len' variable would make his more readable. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5203#note_63339
participants (3)
-
Connor McAdams -
Connor McAdams (@cmcadams) -
Hans Leidekker (@hans)