bin/52691: str[n][case]cmp may cause segmentation violationwith NULL pointers passed

Peter Pentchev roam at ringlet.net
Tue May 27 01:34:43 PDT 2003


On Tue, May 27, 2003 at 12:20:37PM +0400, Seva Gluschenko wrote:
> Message of Dag-Erling Smorgrav at May 26 13:53 ...
> 
> DS> Synopsis: str[n][case]cmp may cause segmentation violation with NULL pointers passed
> DS>
> DS> State-Changed-From-To: open->closed
> DS> State-Changed-By: des
> DS> State-Changed-When: Mon May 26 13:53:02 PDT 2003
> DS> State-Changed-Why:
> DS> The bug is in the application that passes NULL to strcmp.
> 
> Well, sir, can you please quote me some ISO C89 or another standard
> which allows str*cmp not to care about NULL pointers?

I think that in this case, the burden just might be on the programmer;
with all due respect, could you quote any part of the standard that
specifies that str[n]cmp behaves in a special way about NULL pointers?
In my experience, such behavior is usually explicitly documented, such
as the EBADF or EINVAL error returns from select(2), under an 'ERRORS'
or similar section of the standard.  The SUSv3 description of
strncmp(3), available online for a free registration at
http://www.unix-systems.org/single_unix_specification/, does not seem to
mention NULL pointers or error conditions anywhere, except for the 'no
errors are defined' sentence in the 'ERRORS' section.

G'luck,
Peter

-- 
Peter Pentchev	roam at ringlet.net    roam at sbnd.net    roam at FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
Hey, out there - is it *you* reading me, or is it someone else?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-bugs/attachments/20030527/707f684f/attachment.bin


More information about the freebsd-bugs mailing list