Re: [PHP-DEV] emalloc() troubles
In mail.php.internals, Ari Pollak [EMAIL PROTECTED] wrote: Hi there, I'm trying to hack mail.c to automatically pass a -f argument to qmail with a return address, so that the Return-path of the message is not always root@blah. Anyway, I seem to have been successful in this endeavor, but I have a slight problem - whenever my code gets executed, I get two errors output: Simple fix in PHP code (not source): putenv(QMAILSUSER=username); putenv(QMAILSHOST=mydomain.com); No need to hack up mail.c Paul, aka Qube -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
Derick Rethans wrote: On Sat, 28 Dec 2002, Yasuo Ohgaki wrote: PHP shouldn't leak memory even if output/input from/to external program differs. It seems it's a PHP problem for this matter. If you had read the thread you would have seen that the memory leak is only there in his patch. I realized that now. Anyway, if there is problem with qmail, I'll fix it iff I think it's really a problem. Ari hasn't sent me detailed problem description, yet. -- Yasuo Ohgaki Derick Ari Pollak wrote: Unless you come up with a way to migrate 500+ virtualhosts to some other MTA, no, that is not feasible. You can think of qmail like minix in both author and license, in that the author is really arrogant about changing the way his software behaves even though it's not standards-compliant, and you can't distribute modified binaries. And qmail has been on the same version for many years, so nobody is expecting him to actually put out a new version anytime soon. In any case, I'm not expecting any qmail patch to actually go into PHP, but I'd really like to get this memory leak fixed for those who need this patch (me). On Fri, Dec 27, 2002 at 11:00:32AM -0500, George Schlossnagle wrote: qmail devs == djb, right? If his support doesn't suffice (and you cant find it in the enormous un-merged patch contributions that seem to litter the qmail community websites), might I suggest a new MTA? Exim works quite nicely. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
Again, I told you that I already fixed the problem from within PHP, but there's just one memory leak that I can't track down. On Sun, Dec 29, 2002 at 06:39:18PM +0900, Yasuo Ohgaki wrote: I realized that now. Anyway, if there is problem with qmail, I'll fix it iff I think it's really a problem. Ari hasn't sent me detailed problem description, yet. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
I didn't know you have cvs access. Then I'll leave the problem alone :) -- Yasuo Ohgaki Ari Pollak wrote: Again, I told you that I already fixed the problem from within PHP, but there's just one memory leak that I can't track down. On Sun, Dec 29, 2002 at 06:39:18PM +0900, Yasuo Ohgaki wrote: I realized that now. Anyway, if there is problem with qmail, I'll fix it iff I think it's really a problem. Ari hasn't sent me detailed problem description, yet. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
On Sat, 28 Dec 2002, Yasuo Ohgaki wrote: PHP shouldn't leak memory even if output/input from/to external program differs. It seems it's a PHP problem for this matter. If you had read the thread you would have seen that the memory leak is only there in his patch. Derick Ari Pollak wrote: Unless you come up with a way to migrate 500+ virtualhosts to some other MTA, no, that is not feasible. You can think of qmail like minix in both author and license, in that the author is really arrogant about changing the way his software behaves even though it's not standards-compliant, and you can't distribute modified binaries. And qmail has been on the same version for many years, so nobody is expecting him to actually put out a new version anytime soon. In any case, I'm not expecting any qmail patch to actually go into PHP, but I'd really like to get this memory leak fixed for those who need this patch (me). On Fri, Dec 27, 2002 at 11:00:32AM -0500, George Schlossnagle wrote: qmail devs == djb, right? If his support doesn't suffice (and you cant find it in the enormous un-merged patch contributions that seem to litter the qmail community websites), might I suggest a new MTA? Exim works quite nicely. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
On Fri, 27 Dec 2002, Daniel Lorch wrote: hi, This works perfectly, there's just a single memory leak that keeps happening that I can't get rid of. My version doesn't leak :) At least I think it doesn't. If you're bored, have a look at it: http://marc.theaimsgroup.com/?l=php-devm=103927629711494w=2 But your version has the advantage of introducing the ini-parameter qmail_compat. After some investigations, I believe that this IS truly a bug in qmail (uh-oh, bug in qmail? impossible? no!): 4.7. Mail sent from anonymous, particularly by daemons. http://www-dt.e-technik.uni-dortmund.de/~ma/qmail-bugs.html Although this is quite low-priority, someone of the Dev-Team might want to reconsider adding this (Ari's) patch to the main branch? Appears to be a common problem. I could name you several people on PHP-De and qmail who were asking the same thing. If it is a bug in qmail, then the qmail devs should fix it and IMO it would be suboptimal to add hacks in PHP to fix bugs in qmail. Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
The problem is that there are no qmail devs, and it's easier to fix in PHP than in qmail. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
On Fri, 27 Dec 2002, Ari Pollak wrote: The problem is that there are no qmail devs, and it's easier to fix in PHP than in qmail. uhm, isn't qmail djb's replacement for sendmail? So I assume he wrote it right? I would be against adding hacks to PHP to work around bugs in qmail (or any other mailer). Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
qmail devs == djb, right? If his support doesn't suffice (and you cant find it in the enormous un-merged patch contributions that seem to litter the qmail community websites), might I suggest a new MTA? Exim works quite nicely. George On Friday, December 27, 2002, at 10:49 AM, Ari Pollak wrote: The problem is that there are no qmail devs, and it's easier to fix in PHP than in qmail. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
Unless you come up with a way to migrate 500+ virtualhosts to some other MTA, no, that is not feasible. You can think of qmail like minix in both author and license, in that the author is really arrogant about changing the way his software behaves even though it's not standards-compliant, and you can't distribute modified binaries. And qmail has been on the same version for many years, so nobody is expecting him to actually put out a new version anytime soon. In any case, I'm not expecting any qmail patch to actually go into PHP, but I'd really like to get this memory leak fixed for those who need this patch (me). On Fri, Dec 27, 2002 at 11:00:32AM -0500, George Schlossnagle wrote: qmail devs == djb, right? If his support doesn't suffice (and you cant find it in the enormous un-merged patch contributions that seem to litter the qmail community websites), might I suggest a new MTA? Exim works quite nicely. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
PHP shouldn't leak memory even if output/input from/to external program differs. It seems it's a PHP problem for this matter. Are you sure your input to mail() is RFC compliant? Even if input is not RFC compliant, PHP shouldn't leak memory, though. -- Yasuo Ohgaki Ari Pollak wrote: Unless you come up with a way to migrate 500+ virtualhosts to some other MTA, no, that is not feasible. You can think of qmail like minix in both author and license, in that the author is really arrogant about changing the way his software behaves even though it's not standards-compliant, and you can't distribute modified binaries. And qmail has been on the same version for many years, so nobody is expecting him to actually put out a new version anytime soon. In any case, I'm not expecting any qmail patch to actually go into PHP, but I'd really like to get this memory leak fixed for those who need this patch (me). On Fri, Dec 27, 2002 at 11:00:32AM -0500, George Schlossnagle wrote: qmail devs == djb, right? If his support doesn't suffice (and you cant find it in the enormous un-merged patch contributions that seem to litter the qmail community websites), might I suggest a new MTA? Exim works quite nicely. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
PHP isn't leaking memory, my modification to the mail() function is leaking memory, as said earlier in this thread, which is what's troubling me because I can't track down what's leaking. Yasuo Ohgaki said: PHP shouldn't leak memory even if output/input from/to external program differs. It seems it's a PHP problem for this matter. Are you sure your input to mail() is RFC compliant? Even if input is not RFC compliant, PHP shouldn't leak memory, though. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
Ari Pollak wrote: PHP isn't leaking memory, my modification to the mail() function is leaking memory, as said earlier in this thread, which is what's troubling me because I can't track down what's leaking. Ah. I see. I'm using qmail, but I don't realize problem you have mentioned. What kind of address format are you using? Please send me to a a short reproducing script. If I think the problem should be took care of, I'll take care of it. -- Yasuo Ohgaki Yasuo Ohgaki said: PHP shouldn't leak memory even if output/input from/to external program differs. It seems it's a PHP problem for this matter. Are you sure your input to mail() is RFC compliant? Even if input is not RFC compliant, PHP shouldn't leak memory, though. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] emalloc() troubles
Hi there, I'm trying to hack mail.c to automatically pass a -f argument to qmail with a return address, so that the Return-path of the message is not always root@blah. Anyway, I seem to have been successful in this endeavor, but I have a slight problem - whenever my code gets executed, I get two errors output: /home/ari/php-4.3.0RC4/ext/standard/mail.c(235) : Freeing 0x088F6524 (51 bytes), script=/home/ari/public_html/mail.php /home/ari/php-4.3.0RC4/ext/standard/mail.c(229) : Freeing 0x088F647C (23 bytes), script=/home/ari/public_html/mail.php Line 229 and 235 are the following, respectively: qmail_from = emalloc(strlen(temp) + 3); sendmail_cmd = emalloc(strlen(sendmail_path) + strlen(qmail_from) + 2); I efree() both temp and qmail_from when they're done being used, but I can't seem to find why exactly this message is popping up. Both temp and qmail_from seem to be valid strings, and those are the only two strings I create myself that are used. Any ideas? What else could cause the Freeing error message? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
On Thu, 26 Dec 2002, Ari Pollak wrote: Hi there, I'm trying to hack mail.c to automatically pass a -f argument to qmail with a return address, so that the Return-path of the message is not always root@blah. Anyway, I seem to have been successful in this endeavor, but I have a slight problem - whenever my code gets executed, I get two errors output: /home/ari/php-4.3.0RC4/ext/standard/mail.c(235) : Freeing 0x088F6524 (51 bytes), script=/home/ari/public_html/mail.php /home/ari/php-4.3.0RC4/ext/standard/mail.c(229) : Freeing 0x088F647C (23 bytes), script=/home/ari/public_html/mail.php Line 229 and 235 are the following, respectively: qmail_from = emalloc(strlen(temp) + 3); sendmail_cmd = emalloc(strlen(sendmail_path) + strlen(qmail_from) + 2); I efree() both temp and qmail_from when they're done being used, but I can't seem to find why exactly this message is popping up. Both temp and qmail_from seem to be valid strings, and those are the only two strings I create myself that are used. Any ideas? What else could cause the Freeing error message? Most likely you return from the function before you efree the variables (with RETURN_* or return for example). regards, Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
Nope, the only thing between the emalloc() and the efree()s are strcpy, strcat, and php_escape_shell_cmd calls. On Thu, Dec 26, 2002 at 11:48:40AM +0100, Derick Rethans wrote: Most likely you return from the function before you efree the variables (with RETURN_* or return for example). - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- ___ ___ / _ | / _ \ Ari Pollak - [EMAIL PROTECTED] - www.aripollak.com / __ |/ ___/ /_/ |_/_/ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
In case it helps anyone to have the entire code to look at, attached is a patch against mail.c that contains all my changes. On Thu, 26 Dec 2002, Ari Pollak wrote: Hi there, I'm trying to hack mail.c to automatically pass a -f argument to qmail with a return address, so that the Return-path of the message is not always root@blah. Anyway, I seem to have been successful in this endeavor, but I have a slight problem - whenever my code gets executed, I get two errors output: /home/ari/php-4.3.0RC4/ext/standard/mail.c(235) : Freeing 0x088F6524 (51 bytes), script=/home/ari/public_html/mail.php /home/ari/php-4.3.0RC4/ext/standard/mail.c(229) : Freeing 0x088F647C (23 bytes), script=/home/ari/public_html/mail.php Line 229 and 235 are the following, respectively: qmail_from = emalloc(strlen(temp) + 3); sendmail_cmd = emalloc(strlen(sendmail_path) + strlen(qmail_from) + 2); I efree() both temp and qmail_from when they're done being used, but I can't seem to find why exactly this message is popping up. Both temp and qmail_from seem to be valid strings, and those are the only two strings I create myself that are used. Any ideas? What else could cause the Freeing error message? --- php-4.3.0RC4/ext/standard/mail.c~ Wed Dec 25 21:18:14 2002 +++ php-4.3.0RC4/ext/standard/mail.cThu Dec 26 04:50:57 2002 @@ -137,6 +138,55 @@ } /* }}} */ +/* {{{ qmail_email + Returns an e-mail address if found in a From: header +*/ +char *qmail_email(char *headers) +{ + int len = 0; + char *temp = NULL, *loc1 = NULL, *loc2 = NULL; + char *qmail_from = NULL; + + temp = strstr(headers, From: ); + if(temp != NULL) { /* From: header found, do everything */ + loc1 = strchr(temp, ''); + if(loc1 != NULL) { /* found, get text between brackets */ + loc1 += 1; + loc2 = strchr(loc1, ''); + if(loc2 != NULL) { /* found, text should end one char before +*/ + loc2 -= 1; + len = loc2 - loc1 + 1; + } else { /* not found, don't bother with any of this */ + return NULL; + } + } else { /* no , just get all the text afterwards */ + loc1 = temp + 6; + loc2 = strchr(loc1, '\n'); + if(loc2 != NULL) { /* newline found, we're almost set*/ + loc2 -= 1; + len = loc2 - loc1 + 1; + } + } + if(loc2 == NULL) { /* Go until the end of the string */ + qmail_from = estrdup(loc1); + } else { /* Only copy until loc2 */ + qmail_from = emalloc(len + 1); + temp = qmail_from; + while(loc1 = loc2) { + *temp = *loc1; + loc1++; + temp++; + } + *temp = '\0'; + } + return qmail_from; + } + else { + return NULL; + } +} +/* }}} */ + /* {{{ php_mail */ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd TSRMLS_DC) @@ -147,6 +197,7 @@ #endif FILE *sendmail; int ret; + char *temp = NULL, *qmail_from = NULL; char *sendmail_path = INI_STR(sendmail_path); char *sendmail_cmd = NULL; @@ -172,6 +223,23 @@ strcpy (sendmail_cmd, sendmail_path); strcat (sendmail_cmd, ); strcat (sendmail_cmd, extra_cmd); + } else if(INI_STR(qmail_compat) headers != NULL) { + temp = qmail_email(headers); + if(temp != NULL) { /* return e-mail address found */ + qmail_from = emalloc(strlen(temp) + 3); + strcpy(qmail_from, -f); + strcat(qmail_from, temp); + qmail_from = php_escape_shell_cmd(qmail_from); + efree(temp); + + sendmail_cmd = emalloc(strlen(sendmail_path) + +strlen(qmail_from) + 2); + strcpy(sendmail_cmd, sendmail_path); + strcat(sendmail_cmd, ); + strcat(sendmail_cmd, qmail_from); + efree(qmail_from); + } else { + sendmail_cmd = sendmail_path; + } } else { sendmail_cmd = sendmail_path; } -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
On Thu, 26 Dec 2002, Ari Pollak wrote: Nope, the only thing between the emalloc() and the efree()s are strcpy, strcat, and php_escape_shell_cmd calls. ah, the escape_shell thing duplicates your string. Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
Doh, I hadn't even thought of that, because it was called the same way earlier in the function, but I just realized that line assigned it to one of the function parameters, so it doesn't actually overwrite the original pointer (call by value). That got rid of one of the memleak errors, but the 51-byte leak on line 230 still seems to be there. Line 230 starts with: sendmail_cmd = emalloc(strlen(sendmail_path) + strlen(qmail_from) + 2); strcpy(sendmail_cmd, sendmail_path); strcat(sendmail_cmd, ); strcat(sendmail_cmd, qmail_from); efree(qmail_from); that's almost verbatim from stock code already in the function, which doesn't give an error. On Thu, Dec 26, 2002 at 08:11:01PM +0100, Derick Rethans wrote: On Thu, 26 Dec 2002, Ari Pollak wrote: Nope, the only thing between the emalloc() and the efree()s are strcpy, strcat, and php_escape_shell_cmd calls. ah, the escape_shell thing duplicates your string. Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- ___ ___ / _ | / _ \ Ari Pollak - [EMAIL PROTECTED] - www.aripollak.com / __ |/ ___/ /_/ |_/_/ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
hi, Hi there, I'm trying to hack mail.c to automatically pass a -f argument to qmail with a return address, so that the Return-path of the message is not always root@blah. Anyway, I seem to have been successful in this endeavor, but I have a slight problem - whenever my code gets executed, I get two errors output: And people were laughing at me, when I suggested that, right? @Ari I could give you my patch, If you'd like to have a look at it. Not very nicely written, though, but works fine. -daniel -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
This works perfectly, there's just a single memory leak that keeps happening that I can't get rid of. On Fri, Dec 27, 2002 at 02:33:37AM +0100, Daniel Lorch wrote: hi, Hi there, I'm trying to hack mail.c to automatically pass a -f argument to qmail with a return address, so that the Return-path of the message is not always root@blah. Anyway, I seem to have been successful in this endeavor, but I have a slight problem - whenever my code gets executed, I get two errors output: And people were laughing at me, when I suggested that, right? @Ari I could give you my patch, If you'd like to have a look at it. Not very nicely written, though, but works fine. -daniel -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] emalloc() troubles
hi, This works perfectly, there's just a single memory leak that keeps happening that I can't get rid of. My version doesn't leak :) At least I think it doesn't. If you're bored, have a look at it: http://marc.theaimsgroup.com/?l=php-devm=103927629711494w=2 But your version has the advantage of introducing the ini-parameter qmail_compat. After some investigations, I believe that this IS truly a bug in qmail (uh-oh, bug in qmail? impossible? no!): 4.7. Mail sent from anonymous, particularly by daemons. http://www-dt.e-technik.uni-dortmund.de/~ma/qmail-bugs.html Although this is quite low-priority, someone of the Dev-Team might want to reconsider adding this (Ari's) patch to the main branch? Appears to be a common problem. I could name you several people on PHP-De and qmail who were asking the same thing. -daniel -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php