response is ecalloc()d in Ack() itself and efree()d here
because the content is in *error_message now */
#define SMTP_ERROR_RESPONSE(response) { \
- if (NULL != (*error_message = ecalloc(1, sizeof(SMTP_ERROR_RESPONSE_SPEC) + strlen(response)))) { \
- snprintf(*error_message, sizeof(SMTP_ERROR_RESPONSE_SPEC) + strlen(response), SMTP_ERROR_RESPONSE_SPEC, response); \
+ if (response && error_message) { \
+ if (NULL != (*error_message = ecalloc(1, sizeof(SMTP_ERROR_RESPONSE_SPEC) + strlen(response)))) { \
+ snprintf(*error_message, sizeof(SMTP_ERROR_RESPONSE_SPEC) + strlen(response), SMTP_ERROR_RESPONSE_SPEC, response); \
+ } \
+ efree(response); \
} \
- efree(response); \
}
#ifndef THREAD_SAFE
return W32_SM_SENDMAIL_FROM_MALFORMED;
}
-
tempMailTo = estrdup(mailTo);
/* Send mail to all rcpt's */
token = strtok(tempMailTo, ",");
token = strtok(tempMailTo, ",");
while(token != NULL)
{
- snprintf(Buffer, MAIL_BUFFER_SIZE, "RCPT TO:<%s>\r\n", token);
- if ((res = Post(Buffer)) != SUCCESS) {
- efree(tempMailTo);
+ sprintf(Buffer, "RCPT TO:<%s>\r\n", token);
+ if ((res = Post(Buffer)) != SUCCESS)
return (res);
- }
if ((res = Ack(&server_response)) != SUCCESS) {
SMTP_ERROR_RESPONSE(server_response);
- efree(tempMailTo);
return (res);
}
token = strtok(NULL, ",");
}
}
}
+
if (mailBcc && *mailBcc) {
tempMailTo = estrdup(mailBcc);
/* Send mail to all rcpt's */
}
}
if(xheaders){
- if (!addToHeader(&header_buffer, "%s", xheaders)) {
+ if (!addToHeader(&header_buffer, "%s\r\n", xheaders)) {
goto PostHeader_outofmem;
}
}