Skip to content

Commit 6c635f9

Browse files
fix format-truncation on 64bit
GCC 10.x rightfully complains about out-of-bounds snprintf operation on 64bit systems, where size_t could be 64bit sized. Cast bytes_read down to 32bit and printf it without specifying input format Signed-off-by: Konrad Weihmann <[email protected]>
1 parent 7fbb08c commit 6c635f9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Release/src/http/common/http_helpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ size_t chunked_encoding::add_chunked_delimiters(_Out_writes_(buffer_size) uint8_
8888
#ifdef _WIN32
8989
sprintf_s(buffer, sizeof(buffer), "%8IX", bytes_read);
9090
#else
91-
snprintf(buffer, sizeof(buffer), "%8zX", bytes_read);
91+
snprintf(buffer, sizeof(buffer), "%8X", (std::uint32_t)bytes_read);
9292
#endif
9393
memcpy(&data[0], buffer, 8);
9494
while (data[offset] == ' ')

0 commit comments

Comments
 (0)