Subject: Re: [PATCH iproute2] tc: u32: check return value from snprintf

From: Stephen Hemminger <[email-masked]>
Date: Mon, 12 Feb 2024 08:53:58 -0800

On Mon, 12 Feb 2024 15:24:49 +0800
Hangbin Liu <[email-masked]> wrote:

> On Sat, Feb 10, 2024 at 05:04:23PM -0800, Stephen Hemminger wrote:
> > Add assertion to check for case of snprintf failing (bad format?)
> > or buffer getting full.
> > 
> > Signed-off-by: Stephen Hemminger <[email-masked]>  
> 
> Hi Stephen,
> 
> Is there a bug report or something else that we only do the assertion
> for tc/f_u32.c?
> 
> Thanks
> Hangbin

No bug, it is not possible to trigger with current code.
Return of < 0 only happens with improper format string,
and the overrun would only happen if buffer was not big enough
The bsize is SPRINT_BUF() which is 64 bytes.

It is more a way to avoid some code checker complaining in future.