Possible Bug in FCGI_gets

Darryl Wagoner (darryl@sai.com)
Fri, 14 Mar 1997 19:46:47 -0500

Message-Id: <3329F177.167EB0E7@sai.com>
Date: Fri, 14 Mar 1997 19:46:47 -0500
From: Darryl Wagoner <darryl@sai.com>
To: fastcgi-developers@OpenMarket.com
Subject: Possible Bug in FCGI_gets

While doing a C++ Builder NT port of libfcgi I found the follow
code that looks like a bug:

char *FCGI_gets(char *str)
{
    char *s;
    int c;
    for (s = str; (c = FCGI_getchar() != '\n');) {
        if(c == EOF) {
            if(s == str) 
                return NULL;
            else
                break;
        } else
            *s++ = c;
    }
    *s = 0;
    return str;
}
  
Shouldn't be:

     for (s = str; (c = FCGI_getchar()) != '\n';) 

in my book != has a higher precedence than =, which would
mean that 'c' would be set to true or false.  In which case
c would never be equal to EOF.

--
Darryl Wagoner		darryl@sai.com   http://www.sai.com/
Office: 603.672.0736   		Fax: 603-672-4846
Beware of self-styled experts: an ex is a has-been, and a spurt is a
drip under pressure.