httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Richards <p.richa...@elsevier.co.uk>
Subject Re: [PATCH] Fix for vbprintf("%s") and NULL pointers
Date Mon, 17 Feb 1997 10:27:16 GMT
Dean Gaudet <dgaudet@arctic.org> writes:

> >     The attached patch seems to do the trick.  While it's sometimes
> >     reasonable for a routine to die horribly if given bogus arguments,
> >     vbprintf() extends printf(), so IMHO it shouldn't introduce a bug
> >     in the basic printf functionality it's emulating.. ?

This is totally wrong.

Passing a null reference to printf results in "undetermined"
behaviour.  I really dislike printf's that try to be clever and print
(null). That's braindead behaviour in my opinion though it is allowed.
It's almost always the case that if you pass a null pointer to printf
it's because of a bug in your code and bugs in C code should result in
faults not non-fatal messages. Instead of having broken code fail
you've now made it work even though it's probably still broken.

This argument is akin to the one as to whether strcpy should check
for null pointers. It shouldn't, it's not the job of library functions
to protect the programmer from coding errors.

-- 
  Dr Paul Richards. Originative Solutions Ltd.  (Netcraft Ltd. contractor)
  Elsevier Science TIS online journal project.
  Email: p.richards@elsevier.co.uk
  Phone: 0370 462071 (Mobile), +44 (0)1865 843155

Mime
View raw message