This repository was archived by the owner on Jun 1, 2026. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change the format string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because in GCC 12.x I am getting error messages while compiling the original cpprestsdk in Linux. And then, I refactored and made these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also using GCC 12.x, but the format string itself is not the issue for the string truncation warning. You're basically changing the behavior.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While compiling the original sources, I am getting this error:
[ 1%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/client/http_client.cpp.o
[ 1%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/client/http_client_msg.cpp.o
[ 2%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/common/http_compression.cpp.o
[ 3%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/common/http_helpers.cpp.o
[ 3%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/common/http_msg.cpp.o
[ 4%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/listener/http_listener.cpp.o
[ 5%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/listener/http_server_api.cpp.o
[ 6%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/oauth/oauth1.cpp.o
[ 6%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/listener/http_listener_msg.cpp.o
[ 6%] Building CXX object Release/src/CMakeFiles/cpprest.dir/utilities/web_utilities.cpp.o
[ 7%] Building CXX object Release/src/CMakeFiles/cpprest.dir/utilities/asyncrt_utils.cpp.o
[ 9%] Building CXX object Release/src/CMakeFiles/cpprest.dir/utilities/base64.cpp.o
[ 9%] Building CXX object Release/src/CMakeFiles/cpprest.dir/websockets/client/ws_msg.cpp.o
[ 10%] Building CXX object Release/src/CMakeFiles/cpprest.dir/websockets/client/ws_client.cpp.o
[ 10%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/oauth/oauth2.cpp.o
[ 10%] Building CXX object Release/src/CMakeFiles/cpprest.dir/websockets/client/ws_client_wspp.cpp.o
[ 12%] Building CXX object Release/src/CMakeFiles/cpprest.dir/pplx/pplxlinux.cpp.o
[ 12%] Building CXX object Release/src/CMakeFiles/cpprest.dir/json/json.cpp.o
[ 13%] Building CXX object Release/src/CMakeFiles/cpprest.dir/json/json_parsing.cpp.o
[ 14%] Building CXX object Release/src/CMakeFiles/cpprest.dir/pplx/pplx.cpp.o
[ 14%] Building CXX object Release/src/CMakeFiles/cpprest.dir/uri/uri_builder.cpp.o
[ 15%] Building CXX object Release/src/CMakeFiles/cpprest.dir/uri/uri.cpp.o
[ 15%] Building CXX object Release/src/CMakeFiles/cpprest.dir/json/json_serialization.cpp.o
[ 15%] Building CXX object Release/src/CMakeFiles/cpprest.dir/pplx/threadpool.cpp.o
[ 16%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/client/http_client_asio.cpp.o
[ 16%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/client/x509_cert_utilities.cpp.o
[ 17%] Building CXX object Release/src/CMakeFiles/cpprest.dir/streams/fileio_posix.cpp.o
[ 18%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/listener/http_server_asio.cpp.o
/home/fborges/cpprestsdk/Release/src/http/common/http_helpers.cpp: In function ‘size_t web::http::details::chunked_encoding::add_chunked_delimiters(uint8_t*, size_t, size_t)’:
/home/fborges/cpprestsdk/Release/src/http/common/http_helpers.cpp:91:43: error: ‘%8zX’ directive output may be truncated writing between 8 and 16 bytes into a region of size 9 [-Werror=format-truncation=]
91 | snprintf(buffer, sizeof(buffer), "%8zX", bytes_read);
| ^~~~
/home/fborges/cpprestsdk/Release/src/http/common/http_helpers.cpp:91:42: note: directive argument in the range [1, 18446744073709551615]
91 | snprintf(buffer, sizeof(buffer), "%8zX", bytes_read);
| ^~~~~~
/home/fborges/cpprestsdk/Release/src/http/common/http_helpers.cpp:91:17: note: ‘snprintf’ output between 9 and 17 bytes into a destination of size 9
91 | snprintf(buffer, sizeof(buffer), "%8zX", bytes_read);
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Release/src/CMakeFiles/cpprest.dir/build.make:118: Release/src/CMakeFiles/cpprest.dir/http/common/http_helpers.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /usr/include/boost/smart_ptr/detail/sp_thread_sleep.hpp:22,
from /usr/include/boost/smart_ptr/detail/yield_k.hpp:23,
from /usr/include/boost/smart_ptr/detail/spinlock_gcc_atomic.hpp:14,
from /usr/include/boost/smart_ptr/detail/spinlock.hpp:42,
from /usr/include/boost/smart_ptr/detail/spinlock_pool.hpp:25,
from /usr/include/boost/smart_ptr/shared_ptr.hpp:29,
from /usr/include/boost/shared_ptr.hpp:17,
from /usr/include/boost/date_time/time_clock.hpp:17,
from /usr/include/boost/thread/thread_time.hpp:9,
from /usr/include/boost/thread/detail/platform_time.hpp:11,
from /usr/include/boost/thread/pthread/condition_variable.hpp:9,
from /usr/include/boost/thread/condition_variable.hpp:16,
from /home/fborges/cpprestsdk/Release/src/pch/stdafx.h:61,
from /home/fborges/cpprestsdk/Release/src/http/client/http_client_asio.cpp:16:
/usr/include/boost/bind.hpp:36:1: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’
36 | BOOST_PRAGMA_MESSAGE(
| ^~~~~~~~~~~~~~~~~~~~
make[1]: *** [CMakeFiles/Makefile2:545: Release/src/CMakeFiles/cpprest.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cause of the issue is not the format string, it is the buffer size that may force a snprintf truncation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I am going to increase the buffer size and commit again.