-- v2: webservices/tests: Fix -Warray-bounds warning on gcc 13.2.0.
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@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 );
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.