[openib-general] [PATCH] diags/saquery: fix node_desc.description as string usages

Sasha Khapyorsky sashak at voltaire.com
Tue Oct 31 05:50:06 PST 2006


On 22:13 Mon 30 Oct     , Jason Gunthorpe wrote:
> On Tue, Oct 31, 2006 at 06:59:02AM +0200, Sasha Khapyorsky wrote:
> 
> > > > This would be simpler. However some web searching shows that not all
> > > > printf() implementation permits not null terminated arrays even when
> > > > precision is specified (some issues were reported even with glibc-2.3.2).
> > > 
> > > Hmm, couldn't find it.
> > 
> > Look at this for example:
> > http://sourceware.org/ml/bug-glibc/2005-02/msg00123.html
> 
> Interestingly SUSv3 (aka POSIX 2001) only requires the terminating
> null if the precision is longer than the array size.
> 
> s
>     The argument shall be a pointer to an array of char. Bytes from
>     the array shall be written up to (but not including) any
>     terminating null byte. If the precision is specified, no more than
>     that many bytes shall be written. If the precision is not specified or
>     is greater than the size of the array, the application shall ensure
>     that the array contains a null byte. 

The man page printf.3 from man-pages-2.41 states  this even more
exlicitely: "if a precision is specified,  no more than the number
specified are written. If a precision is given, no null byte need be
present;"

Sasha




More information about the general mailing list