d090c61581
- Add gcc12 support (bsc#1196583) New patch: PR28778-gcc-warning-tweak-for-sprintf-precision-parameter.patch New patch: gcc12-c-compatibility-tweak-use-lambdas-instead-of-ptr_fun.patch New patch: gcc12-c-compatibility-re-tweak-for-rhel6-use-function-pointer-instead-of-lambdas-instead-of-ptr_fun.patch New patch: buildrun-for-LKM-backend-add-Wno-infinite-recursion.patch New patch: gcc12-warning-suppression.patch - Add gcc12 support (bsc#1196583) New patch: PR28778-gcc-warning-tweak-for-sprintf-precision-parameter.patch New patch: gcc12-c-compatibility-tweak-use-lambdas-instead-of-ptr_fun.patch New patch: gcc12-c-compatibility-re-tweak-for-rhel6-use-function-pointer-instead-of-lambdas-instead-of-ptr_fun.patch New patch: buildrun-for-LKM-backend-add-Wno-infinite-recursion.patch New patch: gcc12-warning-suppression.patch - Add gcc12 support (bsc#1196583) New patch: PR28778-gcc-warning-tweak-for-sprintf-precision-parameter.patch New patch: gcc12-c-compatibility-tweak-use-lambdas-instead-of-ptr_fun.patch New patch: gcc12-c-compatibility-re-tweak-for-rhel6-use-function-pointer-instead-of-lambdas-instead-of-ptr_fun.patch New patch: buildrun-for-LKM-backend-add-Wno-infinite-recursion.patch New patch: gcc12-warning-suppression.patch OBS-URL: https://build.opensuse.org/request/show/958520 OBS-URL: https://build.opensuse.org/package/show/devel:tools/systemtap?expand=0&rev=134
45 lines
1.6 KiB
Diff
45 lines
1.6 KiB
Diff
From: "Frank Ch. Eigler" <fche@redhat.com>
|
|
Date: Thu, 13 Jan 2022 18:33:15 -0500
|
|
Subject: PR28778: gcc warning tweak for sprintf precision parameter
|
|
Git-repo: git://sourceware.org/git/systemtap.git
|
|
Git-commit: b0422e9e5a539164af75cddcaeb01bceca56bf12
|
|
References: bsc#1196583
|
|
|
|
A precision=-1 sentinel value got interpreted as UINT_MAX in a
|
|
context, leading to diagnostics like:
|
|
|
|
/usr/share/systemtap/runtime/vsprintf.c:341:23: error: 'strnlen' specified bound 4294967295 may exceed maximum object size 2147483647 [-Werror=stringop-overread]
|
|
|
|
Adding a clamp_t() around the parameter field to keep it limited to
|
|
STP_BUFFER_SIZE (8K by default), which is apprx. the limit for a
|
|
single printf.
|
|
|
|
Signed-off-by: Tony Jones <tonyj@suse.de>
|
|
---
|
|
runtime/vsprintf.c | 4 ++--
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/runtime/vsprintf.c b/runtime/vsprintf.c
|
|
index cd31a938b..606f685e8 100644
|
|
--- a/runtime/vsprintf.c
|
|
+++ b/runtime/vsprintf.c
|
|
@@ -338,7 +338,7 @@ _stp_vsprint_memory(char * str, char * end, const char * ptr,
|
|
if (format == 's') {
|
|
if ((unsigned long)ptr < PAGE_SIZE)
|
|
ptr = "<NULL>";
|
|
- len = strnlen(ptr, precision);
|
|
+ len = strnlen(ptr, clamp_t(size_t, precision, 0, STP_BUFFER_SIZE));
|
|
}
|
|
else if (precision > 0)
|
|
len = precision;
|
|
@@ -410,7 +410,7 @@ _stp_vsprint_memory_size(const char * ptr, int width, int precision,
|
|
if (format == 's') {
|
|
if ((unsigned long)ptr < PAGE_SIZE)
|
|
ptr = "<NULL>";
|
|
- len = strnlen(ptr, precision);
|
|
+ len = strnlen(ptr, clamp_t(size_t, precision, 0, STP_BUFFER_SIZE));
|
|
}
|
|
else if (precision > 0)
|
|
len = precision;
|
|
|