[vlc-devel] [PATCH] playlist service discovery NULL pointer dereference

Rémi Denis-Courmont rem at videolan.org
Tue Aug 21 18:59:57 CEST 2007


Le mardi 21 août 2007, Alexander Gall a écrit :
> Pierre,
> > You are right, psz_cat can be NULL (and in fact is most of the
> > time), however a good implementation of xxprintf usually check for
> > NULL string pointers, and print "(null)" accordingly. That's why I
> > wonder on what system are you?
>
> Solaris.  The man page of snprintf() says for "%s":
>
>   The argument must be a pointer to an array of  char...
>   ... An  argument  with a null value will yield undefined results.
>
> I guess it's not safe to assume that every implementation checks the
> arguments.  I'm beginning to understand why these bugs only get
> noticed by me, though :-)

There is nothing in the C standard that says NULL is valid for %s, in 
fact. Solaris is not wrong. But you'll have a hard time fixing all 
occurences of this problem (especially if you include ENOMEM handling).

> > Usually such crash are not hard to resolve, unless they
> > hide a much bigger trouble.
>
> Yes, but a "clean" crash with an assertion failure is still a bit
> better than getting a plain segmentation violation.

Well yes, but hardly better. A clean segfault is fine (such as *NULL) as 
it is relatively easy to debug.

-- 
Rémi Denis-Courmont
http://www.remlab.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20070821/3b3ba09f/attachment.sig>
-------------- next part --------------
_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
http://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list