← Back to team overview

linux-traipu team mailing list archive

[Bug 986015] Re: Uninitialized variable in libdrizzle

 

Hey guys, it's been a few weeks and this is really a P1 for users of
libdrizzle. The library just will not work because of the fix.

Here's the code that I'm referring to in conn.cc:

    int error;
    if (con->revents & POLLOUT)
    {
      drizzle_state_pop(con);
      return DRIZZLE_RETURN_OK; // **** The code below is never executed ****
      socklen_t error_length= sizeof(error);
      int getsockopt_error;
      if ((getsockopt_error= getsockopt(con->fd, SOL_SOCKET, SO_ERROR, (void*)&error, &error_length)) < 1)
      {
        drizzle_set_error(con->drizzle, __func__, strerror(getsockopt_error));
        return DRIZZLE_RETURN_COULD_NOT_CONNECT;
      }

      if (error == 0)
      {
        drizzle_state_pop(con);
        return DRIZZLE_RETURN_OK;
      }
    }
    else if (con->revents & (POLLERR | POLLHUP | POLLNVAL))
    {
      error= 1;
    }

    // **** error is never initialized. If revents is zero and the garbage value of error is nonzero, we'll erronously enter this block
   // **** and go back to connect state.
    if (error)
    {
      con->revents= 0;
      drizzle_state_pop(con);
      drizzle_state_push(con, drizzle_state_connect);
      con->addrinfo_next= con->addrinfo_next->ai_next;
      return DRIZZLE_RETURN_OK;
    }


Looking at the history, it is a bad merge of the patch attached to this bug fix: https://bugs.launchpad.net/drizzle/+bug/879027

-- 
You received this bug notification because you are a member of UBUNTU -
AL - BR, which is subscribed to Drizzle.
https://bugs.launchpad.net/bugs/986015

Title:
  Uninitialized variable in libdrizzle

Status in A Lightweight SQL Database for Cloud Infrastructure and Web Applications:
  New

Bug description:
  In libdrizzle/conn.cc's drizzle_state_connecting(drizzle_con_st *con),
  the int variable error in line 1338 is not initialized.

  Most of the times, the random value assigned is != 0, thus entering
  the block from lines 1363 - 1369. This leads to connections not being
  made and erroring out.

  Line 1338 should be: 
  int error = 0;

  This is the cause of the gearmand bug:
  https://bugs.launchpad.net/gearmand/+bug/955559

To manage notifications about this bug go to:
https://bugs.launchpad.net/drizzle/+bug/986015/+subscriptions


Follow ups

References