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.
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;
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;