|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-08-01 11:50 UTC] grabli_2005 at mail dot ru
Description: ------------ win32\sendmail.c contans static variables and not thread safe. Test script: --------------- It`s not so easy to write test script, because of multithreading and needs of test SMTP server. Expected result: ---------------- mail() funtion should be thread safe. I`ve found this bug years ago. I`ve re-write sendmail.c to not use global variables for php 5.3.0. Also I make it compilable for nix build, so mail() may not start heavy sendmail process and connect directly to local SMTP. You can get this versions here http://lion.rusfur.net/mail_patch.rar Actual result: -------------- mail() fountion is not thread safe. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 16 06:00:02 2025 UTC |
I`ve provide this patches as reference only, not as product quality code replacement. The only difference that I note since 5.3.0 is FormatEmailAddress function, that omits <> around emails. You can check my statment: look at /ext/standard/mail.c function php_mail Here nix path: sendmail = popen(sendmail_cmd, "w"); Here win32 path: if (TSendMail(INI_STR("SMTP"), &tsm_err, &tsm_errmsg, hdr, subject, to, message, NULL, NULL, NULL TSRMLS_CC) == FAILURE) { TSendMail located in win32\sendmail.c here global variables: #ifndef THREAD_SAFE char Buffer[MAIL_BUFFER_SIZE]; /* socket related data */ SOCKET sc; #ifndef NETWARE WSADATA Data; struct hostent *adr; int WinsockStarted; /* values set by the constructor */ char *AppName; #endif /* NETWARE */ SOCKADDR_IN sock_in; char MailHost[HOST_NAME_LEN]; char LocalHost[HOST_NAME_LEN]; #endif It`s placed under #ifndef THREAD_SAFE, but THREAD_SAFE not defined anywhere even when compile with ZTS. More often _THREAD_SAFE used around the code. If you define THREAD_SAFE it`s break sendmail.c compilation, because rest of code uses this variables without any define switch. You can simply debug or place debug printf() in TSendMail and see that this code executed and uses global variables. win32\time.c have same issue.