diff options
| author | Steve Holme <steve_holme@hotmail.com> | 2013-11-15 10:54:47 +0000 | 
|---|---|---|
| committer | Steve Holme <steve_holme@hotmail.com> | 2013-11-15 10:54:23 +0000 | 
| commit | 796333bc5eb34d53843a1da1c173d62e186b5fdb (patch) | |
| tree | 5073d0da5ed97b0c49992d4c2e76aec506d1a794 /lib | |
| parent | f16c0de4e9bbe39089f338b63da93d17e08cb4a1 (diff) | |
smtp: Fixed processing of more than one response when sent in same packet
Added a loop to smtp_statemach_act() in which Curl_pp_readresp() is
called until the cache is drained. Without this multiple responses
received in a single packet could result in a hang or delay.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/smtp.c | 21 | 
1 files changed, 12 insertions, 9 deletions
| diff --git a/lib/smtp.c b/lib/smtp.c index 77d36e909..456ab09ea 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -1352,16 +1352,19 @@ static CURLcode smtp_statemach_act(struct connectdata *conn)    if(pp->sendleft)      return Curl_pp_flushsend(pp); -  /* Read the response from the server */ -  result = Curl_pp_readresp(sock, pp, &smtpcode, &nread); -  if(result) -    return result; +  do { +    /* Read the response from the server */ +    result = Curl_pp_readresp(sock, pp, &smtpcode, &nread); +    if(result) +      return result; -  /* Store the latest response for later retrieval */ -  if(smtpc->state != SMTP_QUIT && smtpcode != 1) -    data->info.httpcode = smtpcode; +    /* Store the latest response for later retrieval if necessary */ +    if(smtpc->state != SMTP_QUIT && smtpcode != 1) +      data->info.httpcode = smtpcode; + +    if(!smtpcode) +      break; -  if(smtpcode) {      /* We have now received a full SMTP server response */      switch(smtpc->state) {      case SMTP_SERVERGREET: @@ -1453,7 +1456,7 @@ static CURLcode smtp_statemach_act(struct connectdata *conn)        state(conn, SMTP_STOP);        break;      } -  } +  } while(!result && smtpc->state != SMTP_STOP && Curl_pp_moredata(pp));    return result;  } | 
