Commit 40f9bb78 authored by Steve Holme's avatar Steve Holme
Browse files

smtp: Reworked smtp_endofresp() to allow for extra capability detection

parent dda53476
Loading
Loading
Loading
Loading
+52 −51
Original line number Diff line number Diff line
@@ -204,9 +204,9 @@ static const struct Curl_handler Curl_handler_smtps_proxy = {
#endif
#endif

/* Function that checks for an ending smtp status code at the start of the
   given string, but also detects the supported authentication mechanisms
   from  the EHLO AUTH response. */
/* Function that checks for an ending SMTP status code at the start of the
   given string, but also detects various capabilities from the EHLO response
   including the supported authentication mechanisms. */
static int smtp_endofresp(struct pingpong *pp, int *resp)
{
  char *line = pp->linestart_resp;
@@ -223,17 +223,17 @@ static int smtp_endofresp(struct pingpong *pp, int *resp)
  if((result = (line[3] == ' ')) != 0)
    *resp = curlx_sltosi(strtol(line, NULL, 10));

  /* Are we processing EHLO command responses? */
  if(smtpc->state == SMTP_EHLO) {
    line += 4;
    len -= 4;

    /* Does the server support the SIZE capability? */
  if(smtpc->state == SMTP_EHLO && len >= 4 && !memcmp(line, "SIZE", 4)) {
    DEBUGF(infof(conn->data, "Server supports SIZE extension.\n"));
    smtpc->size_supported = true;
  }
    if(len >= 4 && !memcmp(line, "SIZE", 4))
      smtpc->size_supported = TRUE;

    /* Do we have the authentication mechanism list? */
  if(smtpc->state == SMTP_EHLO && len >= 5 && !memcmp(line, "AUTH ", 5)) {
    else if(len >= 5 && !memcmp(line, "AUTH ", 5)) {
      line += 5;
      len -= 5;

@@ -274,6 +274,7 @@ static int smtp_endofresp(struct pingpong *pp, int *resp)
        len -= wordlen;
      }
    }
  }

  return result;
}