Bug in FCGI_fread and FCGI_fwrite if size == 0

Ron Newman (rnewman@nfic.com)
Fri, 16 Aug 1996 23:15:23 -0400 (EDT)

From: Ron Newman <rnewman@nfic.com>
Date: Fri, 16 Aug 1996 23:15:23 -0400 (EDT)
Message-Id: <199608170315.XAA03470@janis-joplin.nfic.com>
To: fastcgi-developers@openmarket.com
Subject: Bug in FCGI_fread and FCGI_fwrite if size == 0


If you call fread() or fwrite() with an argument of 0 for
either the "size" or "nitems" parameter, the call should
be a no-op.  

But if you use FastCGI's version of the functions, FCGI_fread, you
could be in for a nasty surprise if you pass a size of 0:

   else if(fp->fcgx_stream) {
        n = FCGX_GetStr((char *) ptr, size * nmemb, fp->fcgx_stream);
        return (n/size);

As you might expect, this kills your program with a zero-divide
trap signal.