Mantis - Resin
Viewing Issue Advanced Details
5632 major always 01-14-14 08:45 09-08-14 17:08
bean  
ferg  
normal  
closed 4.0.38  
fixed  
none    
none 4.0.41  
0005632: calculate_poll_result() returns uninitialized value
In std.c, calculate_poll_result() is supposed to return an int value. But it has a path that doesn't return anything. In that case, the caller gets a bogus return value.

This is especially dangerous as this becomes the return value from std_read()

---------------------
Here is the bad method:
---------------------

static int
calculate_poll_result(connection_t *conn, int poll_result)
{
  if (poll_result == 0) {
    return TIMEOUT_EXN;
  }
  else if (poll_result < 0 && errno != EINTR) {
    return read_exception_status(conn, errno);
  }
  /* missing return here */
}

Notes
(0006390)
bean   
01-16-14 08:26   
Because read_exception_status() already deals with each errno value, this might be a reasonable fix:

static int
calculate_poll_result(connection_t *conn, int poll_result)
{
  if (poll_result == 0) {
    return TIMEOUT_EXN;
  } else {
    return read_exception_status(conn, errno);
  }
}