This is an automated email from the ASF dual-hosted git repository.
maskit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 7220d700a2 Remove the need of `-Wno-stringop-overflow` warning
suppression (#11357)
7220d700a2 is described below
commit 7220d700a20d333ceb9e051864d97ec98878c63f
Author: Pavel Vazharov <[email protected]>
AuthorDate: Thu May 16 18:21:52 2024 +0300
Remove the need of `-Wno-stringop-overflow` warning suppression (#11357)
* Remove the need of -Wno-stringop-overflow warning suppression
The problem was that GCC complained for possibly incorrect usage of
strncat due to the last argument being equal to the source string length.
The last argument of strncat is supposed to be the remaining free space in
the destination buffer.
Replaced the usage of strncat with the ATS function ink_strlcat.
* Fix bogus warning for strncat usage in s3_auth plugin given by GCC 11
The change is to use TSstrlcat instead of strncat.
It seems to me the GCC analyzer is wrong in this case and it issues the
warning because of such usage:
str_concat(&left[loff], (left_size - loff), "/", 1);
and the str_concat internally does
std::min(dst_len, src_len) for the strncat size argument.
So GCC sees the possibility that the last argument of strncat can be
equal to the legnth of the source argument and issues the warning.
---
CMakeLists.txt | 2 +-
lib/swoc/unit_tests/CMakeLists.txt | 1 -
plugins/s3_auth/s3_auth.cc | 2 +-
src/iocore/net/OCSPStapling.cc | 4 ++--
4 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 89f7f6cad7..49b6933ff6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -600,7 +600,7 @@ add_compile_options(-pipe -Wall -Wextra
-Wno-unused-parameter)
add_compile_options(
"$<$<COMPILE_LANGUAGE:CXX>:-Wno-noexcept-type;-Wsuggest-override;-Wno-vla-extension;-fno-strict-aliasing>"
)
-add_compile_options("$<$<CXX_COMPILER_ID:GNU>:-Wno-format-truncation;-Wno-stringop-overflow>")
+add_compile_options("$<$<CXX_COMPILER_ID:GNU>:-Wno-format-truncation>")
if(NOT EXTERNAL_YAML_CPP)
include(subproject_version)
diff --git a/lib/swoc/unit_tests/CMakeLists.txt
b/lib/swoc/unit_tests/CMakeLists.txt
index bd2fe05269..d3a66ff615 100644
--- a/lib/swoc/unit_tests/CMakeLists.txt
+++ b/lib/swoc/unit_tests/CMakeLists.txt
@@ -39,7 +39,6 @@ if(CMAKE_COMPILER_IS_GNUCXX)
-Werror
-Wno-unused-parameter
-Wno-format-truncation
- -Wno-stringop-overflow
-Wno-invalid-offsetof
)
# stop the compiler from complaining about unused variable in structured
binding
diff --git a/plugins/s3_auth/s3_auth.cc b/plugins/s3_auth/s3_auth.cc
index cbd7e3f892..6b8e868dab 100644
--- a/plugins/s3_auth/s3_auth.cc
+++ b/plugins/s3_auth/s3_auth.cc
@@ -758,7 +758,7 @@ str_concat(char *dst, size_t dst_len, const char *src,
size_t src_len)
size_t to_copy = std::min(dst_len, src_len);
if (to_copy > 0) {
- strncat(dst, src, to_copy);
+ TSstrlcat(dst, src, to_copy);
}
return to_copy;
diff --git a/src/iocore/net/OCSPStapling.cc b/src/iocore/net/OCSPStapling.cc
index b1cee4eafc..a9743c7277 100644
--- a/src/iocore/net/OCSPStapling.cc
+++ b/src/iocore/net/OCSPStapling.cc
@@ -1169,8 +1169,8 @@ make_url_for_get(TS_OCSP_REQUEST *req, const char
*base_url)
// Append '/' if base_url does not end with it
if (url->buf()[url->size() - 1] != '/') {
- strncat(url->end(), "/", 1);
- url->fill(1);
+ written = ink_strlcat(url->end(), "/", url->write_avail());
+ url->fill(written);
}
written = ink_strlcat(url->end(), ocsp_escaped, url->write_avail());