The existing check is for truncation, not whether the buffer is full.
However, if the buffer is full (i.e. hs_len == sizeof(header_str) - 1)
then there's no use trying subsequent snprintf() calls because there
will be one byte available that already contains the NUL-terminator.
A subsequent call will just do a no-op truncation.
Check for full buffer instead.
This might be confusing because it isn't the standard check that is
done after snprintf() calls. Is it worth it for a rare corner case?
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
"[%s, %2d",
tvbuf.buf,
level);
- if (state.hs_len >= sizeof(state.header_str)) {
+ if (state.hs_len >= sizeof(state.header_str) - 1) {
goto full;
}
sizeof(state.header_str) - state.hs_len,
", pid=%u",
(unsigned int)getpid());
- if (state.hs_len >= sizeof(state.header_str)) {
+ if (state.hs_len >= sizeof(state.header_str) - 1) {
goto full;
}
}
(unsigned int)getegid(),
(unsigned int)getuid(),
(unsigned int)getgid());
- if (state.hs_len >= sizeof(state.header_str)) {
+ if (state.hs_len >= sizeof(state.header_str) - 1) {
goto full;
}
}
sizeof(state.header_str) - state.hs_len,
", class=%s",
classname_table[cls]);
- if (state.hs_len >= sizeof(state.header_str)) {
- goto full;
- }
}
if (state.hs_len >= sizeof(state.header_str) - 1) {