Commit 10977f57 authored by Kamil Dudka's avatar Kamil Dudka
Browse files

qssl: reflect recent code changes in SSL interface

Reported by Guenter Knauf.
parent ef1ac363
Loading
Loading
Loading
Loading
+15 −8
Original line number Original line Diff line number Diff line
@@ -374,8 +374,9 @@ int Curl_qsossl_shutdown(struct connectdata * conn, int sockindex)
}
}




/* for documentation see Curl_ssl_send() in sslgen.h */
ssize_t Curl_qsossl_send(struct connectdata * conn, int sockindex,
ssize_t Curl_qsossl_send(struct connectdata * conn, int sockindex,
                         const void * mem, size_t len)
                         const void * mem, size_t len, int * curlcode)


{
{
  /* SSL_Write() is said to return 'int' while write() and send() returns
  /* SSL_Write() is said to return 'int' while write() and send() returns
@@ -391,22 +392,26 @@ ssize_t Curl_qsossl_send(struct connectdata * conn, int sockindex,
      /* The operation did not complete; the same SSL I/O function
      /* The operation did not complete; the same SSL I/O function
         should be called again later. This is basicly an EWOULDBLOCK
         should be called again later. This is basicly an EWOULDBLOCK
         equivalent. */
         equivalent. */
      return 0;
      *curlcode = -1; /* EWOULDBLOCK */
      return -1;


    case SSL_ERROR_IO:
    case SSL_ERROR_IO:
      switch (errno) {
      switch (errno) {
      case EWOULDBLOCK:
      case EWOULDBLOCK:
      case EINTR:
      case EINTR:
        return 0;
        *curlcode = -1; /* EWOULDBLOCK */
        return -1;
        }
        }


      failf(conn->data, "SSL_Write() I/O error: %s", strerror(errno));
      failf(conn->data, "SSL_Write() I/O error: %s", strerror(errno));
      *curlcode = CURLE_SEND_ERROR;
      return -1;
      return -1;
    }
    }


    /* An SSL error. */
    /* An SSL error. */
    failf(conn->data, "SSL_Write() returned error %s",
    failf(conn->data, "SSL_Write() returned error %s",
          SSL_Strerror(rc, NULL));
          SSL_Strerror(rc, NULL));
    *curlcode = CURLE_SEND_ERROR;
    return -1;
    return -1;
  }
  }


@@ -414,8 +419,9 @@ ssize_t Curl_qsossl_send(struct connectdata * conn, int sockindex,
}
}




/* for documentation see Curl_ssl_recv() in sslgen.h */
ssize_t Curl_qsossl_recv(struct connectdata * conn, int num, char * buf,
ssize_t Curl_qsossl_recv(struct connectdata * conn, int num, char * buf,
                         size_t buffersize, bool * wouldblock)
                         size_t buffersize, int * curlcode)


{
{
  char error_buffer[120]; /* OpenSSL documents that this must be at
  char error_buffer[120]; /* OpenSSL documents that this must be at
@@ -426,7 +432,6 @@ ssize_t Curl_qsossl_recv(struct connectdata * conn, int num, char * buf,


  buffsize = (buffersize > (size_t)INT_MAX) ? INT_MAX : (int)buffersize;
  buffsize = (buffersize > (size_t)INT_MAX) ? INT_MAX : (int)buffersize;
  nread = SSL_Read(conn->ssl[num].handle, buf, buffsize);
  nread = SSL_Read(conn->ssl[num].handle, buf, buffsize);
  *wouldblock = FALSE;


  if(nread < 0) {
  if(nread < 0) {
    /* failed SSL_read */
    /* failed SSL_read */
@@ -435,21 +440,23 @@ ssize_t Curl_qsossl_recv(struct connectdata * conn, int num, char * buf,


    case SSL_ERROR_BAD_STATE:
    case SSL_ERROR_BAD_STATE:
      /* there's data pending, re-invoke SSL_Read(). */
      /* there's data pending, re-invoke SSL_Read(). */
      *wouldblock = TRUE;
      *curlcode = -1; /* EWOULDBLOCK */
      return -1; /* basically EWOULDBLOCK */
      return -1;


    case SSL_ERROR_IO:
    case SSL_ERROR_IO:
      switch (errno) {
      switch (errno) {
      case EWOULDBLOCK:
      case EWOULDBLOCK:
        *wouldblock = TRUE;
        *curlcode = -1; /* EWOULDBLOCK */
        return -1;
        return -1;
        }
        }


      failf(conn->data, "SSL_Read() I/O error: %s", strerror(errno));
      failf(conn->data, "SSL_Read() I/O error: %s", strerror(errno));
      *curlcode = CURLE_RECV_ERROR;
      return -1;
      return -1;


    default:
    default:
      failf(conn->data, "SSL read error: %s", SSL_Strerror(nread, NULL));
      failf(conn->data, "SSL read error: %s", SSL_Strerror(nread, NULL));
      *curlcode = CURLE_RECV_ERROR;
      return -1;
      return -1;
    }
    }
  }
  }
+6 −2
Original line number Original line Diff line number Diff line
@@ -36,15 +36,19 @@ void Curl_qsossl_close(struct connectdata *conn, int sockindex);
int Curl_qsossl_close_all(struct SessionHandle * data);
int Curl_qsossl_close_all(struct SessionHandle * data);
int Curl_qsossl_shutdown(struct connectdata * conn, int sockindex);
int Curl_qsossl_shutdown(struct connectdata * conn, int sockindex);


/* for documentation see Curl_ssl_send() in sslgen.h */
ssize_t Curl_qsossl_send(struct connectdata * conn,
ssize_t Curl_qsossl_send(struct connectdata * conn,
                         int sockindex,
                         int sockindex,
                         const void * mem,
                         const void * mem,
                         size_t len);
                         size_t len,
                         int * curlcode);

/* for documentation see Curl_ssl_recv() in sslgen.h */
ssize_t Curl_qsossl_recv(struct connectdata * conn, /* connection data */
ssize_t Curl_qsossl_recv(struct connectdata * conn, /* connection data */
                         int num,                   /* socketindex */
                         int num,                   /* socketindex */
                         char * buf,                /* store read data here */
                         char * buf,                /* store read data here */
                         size_t buffersize,         /* max amount to read */
                         size_t buffersize,         /* max amount to read */
                         bool * wouldblock);
                         int * curlcode);


size_t Curl_qsossl_version(char * buffer, size_t size);
size_t Curl_qsossl_version(char * buffer, size_t size);
int Curl_qsossl_check_cxn(struct connectdata * cxn);
int Curl_qsossl_check_cxn(struct connectdata * cxn);
+1 −1
Original line number Original line Diff line number Diff line
@@ -553,7 +553,7 @@ int Curl_read(struct connectdata *conn, /* connection data */
  }
  }


  if(conn->ssl[num].state == ssl_connection_complete) {
  if(conn->ssl[num].state == ssl_connection_complete) {
    int curlcode;
    int curlcode = CURLE_RECV_ERROR;
    nread = Curl_ssl_recv(conn, num, buffertofill, bytesfromsocket, &curlcode);
    nread = Curl_ssl_recv(conn, num, buffertofill, bytesfromsocket, &curlcode);


    if(nread == -1)
    if(nread == -1)