Skip to content

Commit 7afd927

Browse files
committed
Fix the use of "personal" information in To and Cc headers
1 parent cc13af6 commit 7afd927

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

ext/imap/php_imap.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3144,10 +3144,22 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
31443144
char *tempMailTo;
31453145
char *tsm_errmsg = NULL;
31463146
ADDRESS *addr;
3147-
char *bufferTo = NULL, *bufferCc = NULL, *bufferBcc = NULL;
3148-
int offset;
3149-
3147+
char *bufferTo = NULL, *bufferCc = NULL, *bufferBcc = NULL, *bufferHeader = NULL;
3148+
int offset, bufferLen = 0;;
3149+
3150+
if (headers)
3151+
bufferLen += strlen(headers);
3152+
if (to)
3153+
bufferLen += strlen(to) + 6;
3154+
if (cc)
3155+
bufferLen += strlen(cc) + 6;
3156+
3157+
bufferHeader = (char *)emalloc(bufferLen);
3158+
memset(bufferHeader, 0, bufferLen);
31503159
if (to && *to) {
3160+
strcat(bufferHeader, "To: ");
3161+
strcat(bufferHeader, to);
3162+
strcat(bufferHeader, "\r\n");
31513163
tempMailTo = estrdup(to);
31523164
bufferTo = (char *)emalloc(strlen(to));
31533165
offset = 0;
@@ -3168,6 +3180,9 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
31683180
}
31693181

31703182
if (cc && *cc) {
3183+
strcat(bufferHeader, "Cc: ");
3184+
strcat(bufferHeader, cc);
3185+
strcat(bufferHeader, "\r\n");
31713186
tempMailTo = estrdup(cc);
31723187
bufferCc = (char *)emalloc(strlen(cc));
31733188
offset = 0;
@@ -3207,8 +3222,9 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
32073222
}
32083223
}
32093224

3225+
strcat(bufferHeader, headers);
32103226

3211-
if (TSendMail(INI_STR("SMTP"), &tsm_err, &tsm_errmsg, headers, subject, bufferTo, message, bufferCc, bufferBcc, rpath) != SUCCESS) {
3227+
if (TSendMail(INI_STR("SMTP"), &tsm_err, &tsm_errmsg, bufferHeader, subject, bufferTo, message, bufferCc, bufferBcc, rpath) != SUCCESS) {
32123228
if (tsm_errmsg) {
32133229
php_error(E_WARNING, "%s(): %s", get_active_function_name(TSRMLS_C), tsm_errmsg);
32143230
efree(tsm_errmsg);
@@ -3226,6 +3242,9 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
32263242
if (bufferBcc) {
32273243
efree(bufferBcc);
32283244
}
3245+
if (bufferHeader) {
3246+
efree(bufferHeader);
3247+
}
32293248
#else
32303249
if (!INI_STR("sendmail_path")) {
32313250
return 0;

0 commit comments

Comments
 (0)