mirror of
https://github.com/curl/curl.git
synced 2025-01-18 14:04:30 +08:00
smtp: fixed a few uses of size_t that seemed to believe it was signed
Reported-by: Steven M. Schweda
This commit is contained in:
parent
bd6a695545
commit
614bae813e
16
lib/smtp.c
16
lib/smtp.c
@ -343,7 +343,7 @@ static size_t smtp_auth_plain_data(struct connectdata * conn, char * * outptr)
|
||||
plen = strlen(conn->passwd);
|
||||
|
||||
if(2 * ulen + plen + 2 > sizeof plainauth)
|
||||
return -1;
|
||||
return 0;
|
||||
|
||||
memcpy(plainauth, conn->user, ulen);
|
||||
plainauth[ulen] = '\0';
|
||||
@ -361,7 +361,7 @@ static size_t smtp_auth_login_user(struct connectdata * conn, char * * outptr)
|
||||
|
||||
if(!ulen) {
|
||||
*outptr = strdup("=");
|
||||
return *outptr? 1: -1;
|
||||
return *outptr? 1: 0;
|
||||
}
|
||||
|
||||
return Curl_base64_encode(conn->data, conn->user, ulen, outptr);
|
||||
@ -412,10 +412,10 @@ static CURLcode smtp_authenticate(struct connectdata *conn)
|
||||
result = CURLE_LOGIN_DENIED; /* Other mechanisms not supported. */
|
||||
|
||||
if(!result) {
|
||||
if(l <= 0)
|
||||
if(!l)
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
else if(initresp &&
|
||||
l + strlen(mech) <= 512 - 8) { /* AUTH <mech> ...<crlf> */
|
||||
l + strlen(mech) <= 512 - 8) { /* AUTH <mech> ...<crlf> */
|
||||
result = Curl_pp_sendf(&smtpc->pp, "AUTH %s %s", mech, initresp);
|
||||
free(initresp);
|
||||
|
||||
@ -543,7 +543,7 @@ static CURLcode smtp_state_authplain_resp(struct connectdata *conn,
|
||||
else {
|
||||
l = smtp_auth_plain_data(conn, &plainauth);
|
||||
|
||||
if(l <= 0)
|
||||
if(!l)
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
else {
|
||||
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", plainauth);
|
||||
@ -599,7 +599,7 @@ static CURLcode smtp_state_authpasswd_resp(struct connectdata *conn,
|
||||
struct SessionHandle *data = conn->data;
|
||||
size_t plen;
|
||||
size_t l;
|
||||
char * authpasswd;
|
||||
char *authpasswd;
|
||||
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
@ -615,7 +615,7 @@ static CURLcode smtp_state_authpasswd_resp(struct connectdata *conn,
|
||||
else {
|
||||
l = Curl_base64_encode(data, conn->passwd, plen, &authpasswd);
|
||||
|
||||
if(l <= 0)
|
||||
if(!l)
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
else {
|
||||
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", authpasswd);
|
||||
@ -706,7 +706,7 @@ static CURLcode smtp_state_authcram_resp(struct connectdata *conn,
|
||||
/* Encode it to base64 and send it. */
|
||||
l = Curl_base64_encode(data, reply, 0, &rplyb64);
|
||||
|
||||
if(l <= 0)
|
||||
if(!l)
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
else {
|
||||
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", rplyb64);
|
||||
|
Loading…
Reference in New Issue
Block a user