[Date Prev][Date Next] [Chronological] [Thread] [Top]

fgets in result.c



In result.c in servers/slapd/back-shell there is a while
loop to retrieve the results to pass back to the client.

The problem is, the read call that fgets performs may be
interrupted and cause fgets to return NULL when you are
not at the end of file.

I changed to the following,

while ( !feof(fp) ) {
  if ( fgets( line, sizeof(line), fp ) == NULL ) {
    if ( feof(fp) ) continue;
    if ( errno == EINTR ) {
      errno = 0; continue;
    }
    else {
      Debug( LDAP_DEBUG_ANY, "fgets failed: %s\n",strerror(errno), 0, 0 );
      break;
    }
  }
  ...
  ...
  ...

It would probably be best to change to a for loop to avoid an infinite
loop.
 
This problem occured on an Alpha running Digital Unix 4.0F

thanks
KD

---------------------------------------------
E-Mail: douglk00@mh.us.sbphrd.com
Date: 31-Aug-01
Time: 08:59:11

fortune: In 1914, the first crossword puzzle was printed in a newspaper.  The
creator received $4000 down ... and $3000 across.

---------------------------------------------