[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] libxl: make sure string is null-terminated in libxl__prepare_sockaddr_un



Wei Liu writes ("Re: [PATCH] libxl: make sure string is null-terminated in 
libxl__prepare_sockaddr_un"):
> On Wed, Aug 22, 2018 at 12:39:33PM +0100, Ian Jackson wrote:
> > If this new code has any effect at all, it will corrupt the string by
> > truncating it.
> 
> Corrupt? Per your analysis above, isn't the last byte always going to be
> nul? This change is to placate coverity more than anything else.

As I said, if this new code has any effect at all.  In that case the
last byte must be non-nul.  In which case setting it to nul is
truncating it.

If it is necessary to placate Coverity, how about an assert ?

> Isn't setting the last byte to 0 a common pattern to ensure a
> string is null-terminated?

Only if you don't mind truncated it.  Which we do, here.  Which is why
the previous code checks to make sure that it fits, including the
trailing nul.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.