Subject: Re: CVS commit: src/sys
To: None <itojun@iijlab.net>
From: Klaus Klein <kleink@mibh.de>
List: tech-kern
Date: 04/24/2004 20:41:04
On Saturday 24 April 2004 20:22, itojun@iijlab.net wrote:
> >While I believe Simon's suggestion of panic() in the DIAGNOSTIC
> >case is a good idea (in the spirit of DIAGNOSTIC), why not take
> >this one step further and truncate in case of insufficient space
> >if !DIAGNOSTIC?  It's not as if these functions had a significant
> >performance impact (other than their ever-growing code size) so
> >I'd rather pay the expense of such a check than having memory
> >corrupted.
> 
> 	if 2nd arg to snprintf() is smaller than required space, snprintf()
> 	would leave truncated string as a result.

Please read my initial mail again on why this is does not matter for
the case where multiple invocations of snprintf() are made to format
data to a single buffer, as is done in pci_devinfo() (snprintf()
returning the amount space required, not taking into account
truncation).

It won't bite you in the truncating invocation, but there's no way
to avoid it in the subsequent ones.  It's not about snprintf();
it's about how it's being used.


- Klaus