#40392 [Fbk->Opn]: memory leaks in PHP milter SAPI and proposed fix

2007-03-09 Thread tuxracer69 at gmail dot com
 ID:   40392
 User updated by:  tuxracer69 at gmail dot com
 Reported By:  tuxracer69 at gmail dot com
-Status:   Feedback
+Status:   Open
 Bug Type: Unknown/Other Function
 Operating System: Linux 2.6.17-2-686
 PHP Version:  5CVS-2007-02-07 (snap)
 New Comment:

Hi Tony,

I put the patch at the URL below:

http://atpic.com/bug40392.patch.txt

I included the php_getopt.h because the compiler complained about it.

Thanks
Alex


Previous Comments:


[2007-03-09 10:33:23] [EMAIL PROTECTED]

Please upload the patch somewhere (applying copy/pasted patches is
non-trivial).
Why did you need to include php_getopt.h header, I wonder?



[2007-03-08 13:52:10] tuxracer69 at gmail dot com

Hi,
Just to follow up on this bug, the patch above has now been running in
a production server for a month and the whole setup  sendmail+phpmilter
was stable.
Alex



[2007-02-09 08:52:36] tuxracer69 at gmail dot com

oops the exit_status was broken, should be:

diff -u php_milter.c.dist php_milter.c
--- php_milter.c.dist   2007-02-07 10:18:03.0 +
+++ php_milter.c2007-02-09 08:48:03.0 +
@@ -63,6 +63,8 @@
 
 #include "libmilter/mfapi.h"
 
+#include "php_getopt.h"
+
 #define OPTSTRING "ac:d:Def:hnp:vVz:?"
 #define MG(v)  TSRMG(milter_globals_id, zend_milter_globals *, v)
 
@@ -202,7 +204,7 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
-
+   zval_ptr_dtor(param);
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
}
@@ -235,8 +237,8 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
+   zval_ptr_dtor(param);
 
-   FREE_ZVAL(param[0]);
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -275,8 +277,8 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
+   zval_ptr_dtor(param);
 
-   FREE_ZVAL(param[0]);
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -316,7 +318,8 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
+   zval_ptr_dtor(param);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -354,8 +357,9 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
-   FREE_ZVAL(param[1]);
+   zval_ptr_dtor(¶m[0]);
+   zval_ptr_dtor(¶m[1]);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -408,7 +412,7 @@
INIT_PZVAL(param[0]);
 
ZVAL_STRING(&function_name, "milter_body", 0);
-   ZVAL_STRINGL(param[0], bodyp, len, 1);
+   ZVAL_STRINGL(param[0], (char*)bodyp, len, 1); /*alex*/
 
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
@@ -418,7 +422,8 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
+   zval_ptr_dtor(param);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -548,7 +553,7 @@
if (MG(state) != MLFI_INIT) {
php_error(E_WARNING, NOT_INIT,
get_active_function_name(TSRMLS_C));
} else if (zend_parse_parameters(1 TSRMLS_CC, "l", &flags) ==
SUCCESS) {
-   flags = flags &
SMFIF_ADDHDRS|SMFIF_CHGHDRS|SMFIF_CHGBODY|SMFIF_ADDRCPT|SMFIF_DELRCPT;
+   flags = flags &
(SMFIF_ADDHDRS|SMFIF_CHGHDRS|SMFIF_CHGBODY|SMFIF_ADDRCPT|SMFIF_DELRCPT);
smfilter.xxfi_flags = flags;
}
 }
@@ -703,7 +708,7 @@
if (MG(state) != MLFI_EOM) {
php_error(E_WARNING, NOT_EOM,
get_active_function_name(TSRMLS_C));
} else if (zend_parse_parameters(1 TSRMLS_CC, "s", &body, &len)
== SUCCESS) {
-   if (smfi_replacebody(MG(ctx), body, len) == MI_SUCCESS)
{
+   if (smfi_replacebody(MG(ctx), (u_char*)body, len) ==
MI_SUCCESS) {
RETURN_TRUE;
}
}
@@ -732,6 +737,8 @@
 
MG(state) = MLFI_NONE;
MG(initialized) = 0;
+return SUCCESS;
+
 }
 /* }}} */
 
@@ -920,9 +927,7 @@
 /* temporary locals */
int orig_optind=ap_php_optind;
char *orig_optarg=ap_php_optarg;
-   char *arg_free=NULL, **arg_excp=&arg_free;
int interactive=0;
-   char *exec_direct=NULL;
char *param_error=NULL;
 /* end of temporary locals */
 
@@ -1099,7 +1104,7 @@
 
openlog("php-milter", LOG_PID, LOG_MAIL);
 
-   if (exit_stat

#40392 [Opn]: memory leaks in PHP milter SAPI and proposed fix

2007-03-08 Thread tuxracer69 at gmail dot com
 ID:   40392
 User updated by:  tuxracer69 at gmail dot com
 Reported By:  tuxracer69 at gmail dot com
 Status:   Open
 Bug Type: Unknown/Other Function
 Operating System: Linux 2.6.17-2-686
 PHP Version:  5CVS-2007-02-07 (snap)
 New Comment:

Hi,
Just to follow up on this bug, the patch above has now been running in
a production server for a month and the whole setup  sendmail+phpmilter
was stable.
Alex


Previous Comments:


[2007-02-09 08:52:36] tuxracer69 at gmail dot com

oops the exit_status was broken, should be:

diff -u php_milter.c.dist php_milter.c
--- php_milter.c.dist   2007-02-07 10:18:03.0 +
+++ php_milter.c2007-02-09 08:48:03.0 +
@@ -63,6 +63,8 @@
 
 #include "libmilter/mfapi.h"
 
+#include "php_getopt.h"
+
 #define OPTSTRING "ac:d:Def:hnp:vVz:?"
 #define MG(v)  TSRMG(milter_globals_id, zend_milter_globals *, v)
 
@@ -202,7 +204,7 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
-
+   zval_ptr_dtor(param);
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
}
@@ -235,8 +237,8 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
+   zval_ptr_dtor(param);
 
-   FREE_ZVAL(param[0]);
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -275,8 +277,8 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
+   zval_ptr_dtor(param);
 
-   FREE_ZVAL(param[0]);
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -316,7 +318,8 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
+   zval_ptr_dtor(param);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -354,8 +357,9 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
-   FREE_ZVAL(param[1]);
+   zval_ptr_dtor(¶m[0]);
+   zval_ptr_dtor(¶m[1]);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -408,7 +412,7 @@
INIT_PZVAL(param[0]);
 
ZVAL_STRING(&function_name, "milter_body", 0);
-   ZVAL_STRINGL(param[0], bodyp, len, 1);
+   ZVAL_STRINGL(param[0], (char*)bodyp, len, 1); /*alex*/
 
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
@@ -418,7 +422,8 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
+   zval_ptr_dtor(param);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -548,7 +553,7 @@
if (MG(state) != MLFI_INIT) {
php_error(E_WARNING, NOT_INIT,
get_active_function_name(TSRMLS_C));
} else if (zend_parse_parameters(1 TSRMLS_CC, "l", &flags) ==
SUCCESS) {
-   flags = flags &
SMFIF_ADDHDRS|SMFIF_CHGHDRS|SMFIF_CHGBODY|SMFIF_ADDRCPT|SMFIF_DELRCPT;
+   flags = flags &
(SMFIF_ADDHDRS|SMFIF_CHGHDRS|SMFIF_CHGBODY|SMFIF_ADDRCPT|SMFIF_DELRCPT);
smfilter.xxfi_flags = flags;
}
 }
@@ -703,7 +708,7 @@
if (MG(state) != MLFI_EOM) {
php_error(E_WARNING, NOT_EOM,
get_active_function_name(TSRMLS_C));
} else if (zend_parse_parameters(1 TSRMLS_CC, "s", &body, &len)
== SUCCESS) {
-   if (smfi_replacebody(MG(ctx), body, len) == MI_SUCCESS)
{
+   if (smfi_replacebody(MG(ctx), (u_char*)body, len) ==
MI_SUCCESS) {
RETURN_TRUE;
}
}
@@ -732,6 +737,8 @@
 
MG(state) = MLFI_NONE;
MG(initialized) = 0;
+return SUCCESS;
+
 }
 /* }}} */
 
@@ -920,9 +927,7 @@
 /* temporary locals */
int orig_optind=ap_php_optind;
char *orig_optarg=ap_php_optarg;
-   char *arg_free=NULL, **arg_excp=&arg_free;
int interactive=0;
-   char *exec_direct=NULL;
char *param_error=NULL;
 /* end of temporary locals */
 
@@ -1099,7 +1104,7 @@
 
openlog("php-milter", LOG_PID, LOG_MAIL);
 
-   if (exit_status = mlfi_init()) {
+   if ((exit_status = mlfi_init())) {
syslog(1, "mlfi_init failed.");
exit(exit_status);
            }



[2007-02-09 08:10:42] tuxracer69 at gmail dot com

a longer patch aimed at fixing besides the mem leaks the compile
warnings (type cast, declarations, parenthesis).


diff -u php_milter.c.dist php_milter.c
--- php_milter.c.dist   2007-02-07 10:18:03.0 +
+++ php_milter.c2007-02-09 08:01:01.0 +

#40392 [Opn]: memory leaks in PHP milter SAPI and proposed fix

2007-02-09 Thread tuxracer69 at gmail dot com
 ID:   40392
 User updated by:  tuxracer69 at gmail dot com
 Reported By:  tuxracer69 at gmail dot com
 Status:   Open
 Bug Type: Unknown/Other Function
 Operating System: Linux 2.6.17-2-686
 PHP Version:  5CVS-2007-02-07 (snap)
 New Comment:

oops the exit_status was broken, should be:

diff -u php_milter.c.dist php_milter.c
--- php_milter.c.dist   2007-02-07 10:18:03.0 +
+++ php_milter.c2007-02-09 08:48:03.0 +
@@ -63,6 +63,8 @@
 
 #include "libmilter/mfapi.h"
 
+#include "php_getopt.h"
+
 #define OPTSTRING "ac:d:Def:hnp:vVz:?"
 #define MG(v)  TSRMG(milter_globals_id, zend_milter_globals *, v)
 
@@ -202,7 +204,7 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
-
+   zval_ptr_dtor(param);
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
}
@@ -235,8 +237,8 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
+   zval_ptr_dtor(param);
 
-   FREE_ZVAL(param[0]);
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -275,8 +277,8 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
+   zval_ptr_dtor(param);
 
-   FREE_ZVAL(param[0]);
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -316,7 +318,8 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
+   zval_ptr_dtor(param);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -354,8 +357,9 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
-   FREE_ZVAL(param[1]);
+   zval_ptr_dtor(¶m[0]);
+   zval_ptr_dtor(¶m[1]);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -408,7 +412,7 @@
INIT_PZVAL(param[0]);
 
ZVAL_STRING(&function_name, "milter_body", 0);
-   ZVAL_STRINGL(param[0], bodyp, len, 1);
+   ZVAL_STRINGL(param[0], (char*)bodyp, len, 1); /*alex*/
 
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
@@ -418,7 +422,8 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
+   zval_ptr_dtor(param);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -548,7 +553,7 @@
if (MG(state) != MLFI_INIT) {
php_error(E_WARNING, NOT_INIT,
get_active_function_name(TSRMLS_C));
} else if (zend_parse_parameters(1 TSRMLS_CC, "l", &flags) ==
SUCCESS) {
-   flags = flags &
SMFIF_ADDHDRS|SMFIF_CHGHDRS|SMFIF_CHGBODY|SMFIF_ADDRCPT|SMFIF_DELRCPT;
+   flags = flags &
(SMFIF_ADDHDRS|SMFIF_CHGHDRS|SMFIF_CHGBODY|SMFIF_ADDRCPT|SMFIF_DELRCPT);
smfilter.xxfi_flags = flags;
}
 }
@@ -703,7 +708,7 @@
if (MG(state) != MLFI_EOM) {
php_error(E_WARNING, NOT_EOM,
get_active_function_name(TSRMLS_C));
} else if (zend_parse_parameters(1 TSRMLS_CC, "s", &body, &len)
== SUCCESS) {
-   if (smfi_replacebody(MG(ctx), body, len) == MI_SUCCESS)
{
+   if (smfi_replacebody(MG(ctx), (u_char*)body, len) ==
MI_SUCCESS) {
RETURN_TRUE;
}
}
@@ -732,6 +737,8 @@
 
MG(state) = MLFI_NONE;
MG(initialized) = 0;
+return SUCCESS;
+
 }
 /* }}} */
 
@@ -920,9 +927,7 @@
 /* temporary locals */
int orig_optind=ap_php_optind;
char *orig_optarg=ap_php_optarg;
-   char *arg_free=NULL, **arg_excp=&arg_free;
int interactive=0;
-   char *exec_direct=NULL;
char *param_error=NULL;
 /* end of temporary locals */
 
@@ -1099,7 +1104,7 @@
 
openlog("php-milter", LOG_PID, LOG_MAIL);
 
-   if (exit_status = mlfi_init()) {
+   if ((exit_status = mlfi_init())) {
syslog(1, "mlfi_init failed.");
exit(exit_status);
        }


Previous Comments:


[2007-02-09 08:10:42] tuxracer69 at gmail dot com

a longer patch aimed at fixing besides the mem leaks the compile
warnings (type cast, declarations, parenthesis).


diff -u php_milter.c.dist php_milter.c
--- php_milter.c.dist   2007-02-07 10:18:03.0 +
+++ php_milter.c2007-02-09 08:01:01.0 +
@@ -63,6 +63,8 @@
 
 #include "libmilter/mfapi.h"
 
+#include "php_getopt.h"
+
 #define OPTSTRING "ac:d:Def:hnp:vVz:?"
 #define MG(v)  TSRMG(milter_globals_id, zend_milter_globals *, v)
 
@@ -202,7 +204,7 @@
call_user_function(CG(function_

#40392 [Opn]: memory leaks in PHP milter SAPI and proposed fix

2007-02-09 Thread tuxracer69 at gmail dot com
 ID:   40392
 User updated by:  tuxracer69 at gmail dot com
 Reported By:  tuxracer69 at gmail dot com
 Status:   Open
 Bug Type: Unknown/Other Function
 Operating System: Linux 2.6.17-2-686
 PHP Version:  5CVS-2007-02-07 (snap)
 New Comment:

a longer patch aimed at fixing besides the mem leaks the compile
warnings (type cast, declarations, parenthesis).


diff -u php_milter.c.dist php_milter.c
--- php_milter.c.dist   2007-02-07 10:18:03.0 +
+++ php_milter.c2007-02-09 08:01:01.0 +
@@ -63,6 +63,8 @@
 
 #include "libmilter/mfapi.h"
 
+#include "php_getopt.h"
+
 #define OPTSTRING "ac:d:Def:hnp:vVz:?"
 #define MG(v)  TSRMG(milter_globals_id, zend_milter_globals *, v)
 
@@ -202,7 +204,7 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
-
+   zval_ptr_dtor(param);
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
}
@@ -235,8 +237,8 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
+   zval_ptr_dtor(param);
 
-   FREE_ZVAL(param[0]);
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -275,8 +277,8 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
+   zval_ptr_dtor(param);
 
-   FREE_ZVAL(param[0]);
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -316,7 +318,8 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
+   zval_ptr_dtor(param);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -354,8 +357,9 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
-   FREE_ZVAL(param[1]);
+   zval_ptr_dtor(¶m[0]);
+   zval_ptr_dtor(¶m[1]);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -408,7 +412,7 @@
INIT_PZVAL(param[0]);
 
ZVAL_STRING(&function_name, "milter_body", 0);
-   ZVAL_STRINGL(param[0], bodyp, len, 1);
+   ZVAL_STRINGL(param[0], (char*)bodyp, len, 1); /*alex*/
 
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
@@ -418,7 +422,8 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
+   zval_ptr_dtor(param);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -548,7 +553,7 @@
if (MG(state) != MLFI_INIT) {
php_error(E_WARNING, NOT_INIT,
get_active_function_name(TSRMLS_C));
} else if (zend_parse_parameters(1 TSRMLS_CC, "l", &flags) ==
SUCCESS) {
-   flags = flags &
SMFIF_ADDHDRS|SMFIF_CHGHDRS|SMFIF_CHGBODY|SMFIF_ADDRCPT|SMFIF_DELRCPT;
+   flags = flags &
(SMFIF_ADDHDRS|SMFIF_CHGHDRS|SMFIF_CHGBODY|SMFIF_ADDRCPT|SMFIF_DELRCPT);
smfilter.xxfi_flags = flags;
}
 }
@@ -703,7 +708,7 @@
if (MG(state) != MLFI_EOM) {
php_error(E_WARNING, NOT_EOM,
get_active_function_name(TSRMLS_C));
} else if (zend_parse_parameters(1 TSRMLS_CC, "s", &body, &len)
== SUCCESS) {
-   if (smfi_replacebody(MG(ctx), body, len) == MI_SUCCESS)
{
+   if (smfi_replacebody(MG(ctx), (u_char*)body, len) ==
MI_SUCCESS) {
RETURN_TRUE;
}
}
@@ -732,6 +737,7 @@
 
MG(state) = MLFI_NONE;
MG(initialized) = 0;
+   return SUCCESS;
 }
 /* }}} */
 
@@ -920,9 +926,7 @@
 /* temporary locals */
int orig_optind=ap_php_optind;
char *orig_optarg=ap_php_optarg;
-   char *arg_free=NULL, **arg_excp=&arg_free;
int interactive=0;
-   char *exec_direct=NULL;
char *param_error=NULL;
 /* end of temporary locals */
 
@@ -1099,7 +1103,7 @@
 
openlog("php-milter", LOG_PID, LOG_MAIL);
 
-   if (exit_status = mlfi_init()) {
+   if (exit_status == mlfi_init()) {
syslog(1, "mlfi_init failed.");
exit(exit_status);
        }


Previous Comments:


[2007-02-09 07:18:05] tuxracer69 at gmail dot com

Unified diff for the code change above:

diff -u php_milter.c.dist php_milter.c
--- php_milter.c.dist   2007-02-07 10:18:03.0 +
+++ php_milter.c2007-02-07 19:41:54.0 +
@@ -202,7 +202,7 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
-
+   zval_ptr_dtor(param);
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
   

#40392 [Opn]: memory leaks in PHP milter SAPI and proposed fix

2007-02-08 Thread tuxracer69 at gmail dot com
 ID:   40392
 User updated by:  tuxracer69 at gmail dot com
 Reported By:  tuxracer69 at gmail dot com
 Status:   Open
 Bug Type: Unknown/Other Function
 Operating System: Linux 2.6.17-2-686
 PHP Version:  5CVS-2007-02-07 (snap)
 New Comment:

Unified diff for the code change above:

diff -u php_milter.c.dist php_milter.c
--- php_milter.c.dist   2007-02-07 10:18:03.0 +
+++ php_milter.c2007-02-07 19:41:54.0 +
@@ -202,7 +202,7 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
-
+   zval_ptr_dtor(param);
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
}
@@ -235,8 +235,8 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
+   zval_ptr_dtor(param);
 
-   FREE_ZVAL(param[0]);
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -275,8 +275,8 @@
call_user_function(CG(function_table), NULL, &function_name,
&retval, 1, param TSRMLS_CC);
 
MG(state) = MLFI_NONE;
+   zval_ptr_dtor(param);
 
-   FREE_ZVAL(param[0]);
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -316,7 +316,8 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
+   zval_ptr_dtor(param);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -354,8 +355,9 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
-   FREE_ZVAL(param[1]);
+   zval_ptr_dtor(¶m[0]);
+   zval_ptr_dtor(¶m[1]);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
@@ -418,7 +420,8 @@
 
MG(state) = MLFI_NONE;
 
-   FREE_ZVAL(param[0]);
+   zval_ptr_dtor(param);
+
 
if (Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);


Previous Comments:


[2007-02-07 22:10:56] tuxracer69 at gmail dot com

Well, the goal of the sapi is to call PHP code based on SMTP commands a
client sends to a sendmail server, and in that respect I would say 'it
works'.
Although I did not put the code in a production server, (that's what I
eventually plan to do) I would say that the functions do what they are
expected to do.
The memory leaks were really ugly.
I have other warnings at compile time I could have a look at.

I think there is definitely an interest in processing mail with PHP as
after a previous bug we fixed in the milter sapi (Bug #40083) I got
mails of other developers asking questions about the stability of the
sapi.

Perhaps moving this code to PECL would slow down its development at a
moment where interest is growing and a (relatively) small effort may
take the code up to date.

thanks
Alex



[2007-02-07 20:12:48] [EMAIL PROTECTED]

>Could somebody confirm this?
Yes.

This SAPI is orphaned for years, so I would actually like to move it to
PECL (or anywhere else, just because we cannot guarantee if it works at
all). Also looking at the code I can see other problems, one more
reason to remove this SAPI.

--------

[2007-02-07 20:03:20] tuxracer69 at gmail dot com

after digging in the cli SAPI code I tried using zval_ptr_dtor instead
of the FREE_ZVAL macro.

This resolved the issue (at least I do not see the warnings anymore).

Could somebody confirm this?
Thanks
Alex

here is my diff---


diff php_milter.c php_milter.c.dist
205c205
<   zval_ptr_dtor(param);
---
> 
238d237
<   zval_ptr_dtor(param);
239a239
>   FREE_ZVAL(param[0]);
278d277
<   zval_ptr_dtor(param);
279a279
>   FREE_ZVAL(param[0]);
319,320c319
<   zval_ptr_dtor(param);
< 
---
>   FREE_ZVAL(param[0]);
358,360c357,358
<   zval_ptr_dtor(¶m[0]);
<   zval_ptr_dtor(¶m[1]);
< 
---
>   FREE_ZVAL(param[0]);
>   FREE_ZVAL(param[1]);
423,424c421
<   zval_ptr_dtor(param);
< 
---
>   FREE_ZVAL(param[0]);

--------------------

[2007-02-07 19:56:23] tuxracer69 at gmail dot com

Description:

After compiling the last CVS snapshot (5.2) 
./configure \
--with-pgsql --with-curl --with-xml \
--enable-sockets --with-zlib --with-bz2 \
--with-iconv --enable-track-vars --enable-sysvsem \
--enable-sysvshm --enable-inline-optimization \
--with-curl --with-regex=system --with-png \
--enable-discard-path --enable-dbx --enable-memory-limit \
--disable-debug --disable-rpath --with-openssl \
--enable-exif --enable-mbstring  \
--with-xsl=/usr/lib \
--with-milter --disable-cli --disable-cgi --enable-debug

and launching the examp

#40392 [Opn]: memory leaks in PHP milter SAPI and proposed fix

2007-02-07 Thread tuxracer69 at gmail dot com
 ID:   40392
 User updated by:  tuxracer69 at gmail dot com
 Reported By:  tuxracer69 at gmail dot com
 Status:   Open
 Bug Type: Unknown/Other Function
 Operating System: Linux 2.6.17-2-686
 PHP Version:  5CVS-2007-02-07 (snap)
 New Comment:

Well, the goal of the sapi is to call PHP code based on SMTP commands a
client sends to a sendmail server, and in that respect I would say 'it
works'.
Although I did not put the code in a production server, (that's what I
eventually plan to do) I would say that the functions do what they are
expected to do.
The memory leaks were really ugly.
I have other warnings at compile time I could have a look at.

I think there is definitely an interest in processing mail with PHP as
after a previous bug we fixed in the milter sapi (Bug #40083) I got
mails of other developers asking questions about the stability of the
sapi.

Perhaps moving this code to PECL would slow down its development at a
moment where interest is growing and a (relatively) small effort may
take the code up to date.

thanks
Alex


Previous Comments:


[2007-02-07 20:12:48] [EMAIL PROTECTED]

>Could somebody confirm this?
Yes.

This SAPI is orphaned for years, so I would actually like to move it to
PECL (or anywhere else, just because we cannot guarantee if it works at
all). Also looking at the code I can see other problems, one more
reason to remove this SAPI.



[2007-02-07 20:03:20] tuxracer69 at gmail dot com

after digging in the cli SAPI code I tried using zval_ptr_dtor instead
of the FREE_ZVAL macro.

This resolved the issue (at least I do not see the warnings anymore).

Could somebody confirm this?
Thanks
Alex

here is my diff---


diff php_milter.c php_milter.c.dist
205c205
<   zval_ptr_dtor(param);
---
> 
238d237
<   zval_ptr_dtor(param);
239a239
>   FREE_ZVAL(param[0]);
278d277
<   zval_ptr_dtor(param);
279a279
>   FREE_ZVAL(param[0]);
319,320c319
<   zval_ptr_dtor(param);
< 
---
>   FREE_ZVAL(param[0]);
358,360c357,358
<   zval_ptr_dtor(¶m[0]);
<   zval_ptr_dtor(¶m[1]);
< 
---
>   FREE_ZVAL(param[0]);
>   FREE_ZVAL(param[1]);
423,424c421
<   zval_ptr_dtor(param);
< 
---
>   FREE_ZVAL(param[0]);

--------------------

[2007-02-07 19:56:23] tuxracer69 at gmail dot com

Description:

After compiling the last CVS snapshot (5.2) 
./configure \
--with-pgsql --with-curl --with-xml \
--enable-sockets --with-zlib --with-bz2 \
--with-iconv --enable-track-vars --enable-sysvsem \
--enable-sysvshm --enable-inline-optimization \
--with-curl --with-regex=system --with-png \
--enable-discard-path --enable-dbx --enable-memory-limit \
--disable-debug --disable-rpath --with-openssl \
--enable-exif --enable-mbstring  \
--with-xsl=/usr/lib \
--with-milter --disable-cli --disable-cgi --enable-debug

and launching the example milter I was getting the memory leaks
warnings below.

-
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(304) :  Freeing
0xA5E46184 (44 bytes), script=-
/usr/local/php5.2-200702061930/Zend/zend_API.c(819) : Actual location
(location was relayed)
Last leak repeated 1 time
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(196) :  Freeing
0xA5E464
70 (10 bytes), script=-
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(346) :  Freeing
0xA5E466
C4 (3 bytes), script=-
Last leak repeated 5 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/Zend/zend_API.c(1193) :  Freeing
0xA5E466F8 (16 bytes), script=-
Last leak repeated 2 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(229) :  Freeing
0xA5E468A8 (10 bytes), script=-
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/Zend/zend_API.c(1194) :  Freeing
0xA5E468E4 (17 bytes), script=-
Last leak repeated 2 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/Zend/zend_API.c(1196) :  Freeing
0xA5E46958 (35 bytes), script=-
/usr/local/php5.2-200702061930/Zend/zend_hash.c(388) : Actual location
(location was relayed)
Last leak repeated 2 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(411) :  Freeing
0xA5E46E
D8 (43 bytes), script=-
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(347) :  Freeing
0xA5E470
50 (40 bytes), script=-
Last leak repeated 5 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(264) :  Fre

#40392 [Opn]: memory leaks in PHP milter SAPI and proposed fix

2007-02-07 Thread tuxracer69 at gmail dot com
 ID:   40392
 User updated by:  tuxracer69 at gmail dot com
 Reported By:  tuxracer69 at gmail dot com
 Status:   Open
 Bug Type: Unknown/Other Function
 Operating System: Linux 2.6.17-2-686
 PHP Version:  5CVS-2007-02-07 (snap)
 New Comment:

after digging in the cli SAPI code I tried using zval_ptr_dtor instead
of the FREE_ZVAL macro.

This resolved the issue (at least I do not see the warnings anymore).

Could somebody confirm this?
Thanks
Alex

here is my diff---


diff php_milter.c php_milter.c.dist
205c205
<   zval_ptr_dtor(param);
---
> 
238d237
<   zval_ptr_dtor(param);
239a239
>   FREE_ZVAL(param[0]);
278d277
<   zval_ptr_dtor(param);
279a279
>   FREE_ZVAL(param[0]);
319,320c319
<   zval_ptr_dtor(param);
< 
---
>   FREE_ZVAL(param[0]);
358,360c357,358
<   zval_ptr_dtor(¶m[0]);
<   zval_ptr_dtor(¶m[1]);
< 
---
>   FREE_ZVAL(param[0]);
>   FREE_ZVAL(param[1]);
423,424c421
<   zval_ptr_dtor(param);
< 
---
>   FREE_ZVAL(param[0]);


Previous Comments:
----------------

[2007-02-07 19:56:23] tuxracer69 at gmail dot com

Description:

After compiling the last CVS snapshot (5.2) 
./configure \
--with-pgsql --with-curl --with-xml \
--enable-sockets --with-zlib --with-bz2 \
--with-iconv --enable-track-vars --enable-sysvsem \
--enable-sysvshm --enable-inline-optimization \
--with-curl --with-regex=system --with-png \
--enable-discard-path --enable-dbx --enable-memory-limit \
--disable-debug --disable-rpath --with-openssl \
--enable-exif --enable-mbstring  \
--with-xsl=/usr/lib \
--with-milter --disable-cli --disable-cgi --enable-debug

and launching the example milter I was getting the memory leaks
warnings below.

-
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(304) :  Freeing
0xA5E46184 (44 bytes), script=-
/usr/local/php5.2-200702061930/Zend/zend_API.c(819) : Actual location
(location was relayed)
Last leak repeated 1 time
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(196) :  Freeing
0xA5E464
70 (10 bytes), script=-
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(346) :  Freeing
0xA5E466
C4 (3 bytes), script=-
Last leak repeated 5 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/Zend/zend_API.c(1193) :  Freeing
0xA5E466F8 (16 bytes), script=-
Last leak repeated 2 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(229) :  Freeing
0xA5E468A8 (10 bytes), script=-
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/Zend/zend_API.c(1194) :  Freeing
0xA5E468E4 (17 bytes), script=-
Last leak repeated 2 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/Zend/zend_API.c(1196) :  Freeing
0xA5E46958 (35 bytes), script=-
/usr/local/php5.2-200702061930/Zend/zend_hash.c(388) : Actual location
(location was relayed)
Last leak repeated 2 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(411) :  Freeing
0xA5E46E
D8 (43 bytes), script=-
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(347) :  Freeing
0xA5E470
50 (40 bytes), script=-
Last leak repeated 5 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(264) :  Freeing
0xA5E49A
58 (32 bytes), script=-
/usr/local/php5.2-200702061930/Zend/zend_alloc.c(1917) : Actual
location (location was relayed)
Last leak repeated 1 time
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(192) :  Freeing
0xA5E505E8 (16 bytes), script=-
=== Total 29 memory leaks detected ===
---


The TODO file in the distribution mention such leaks.



Reproduce code:
---
the milter.php in the milter sapi distribution 

Expected result:

no memory leaks

Actual result:
--
a lot of memory leaks warnings.





-- 
Edit this bug report at http://bugs.php.net/?id=40392&edit=1


#40392 [NEW]: memory leaks in PHP milter SAPI and proposed fix

2007-02-07 Thread tuxracer69 at gmail dot com
From: tuxracer69 at gmail dot com
Operating system: Linux 2.6.17-2-686
PHP version:  5CVS-2007-02-07 (snap)
PHP Bug Type: Unknown/Other Function
Bug description:  memory leaks in PHP milter SAPI and proposed fix

Description:

After compiling the last CVS snapshot (5.2) 
./configure \
--with-pgsql --with-curl --with-xml \
--enable-sockets --with-zlib --with-bz2 \
--with-iconv --enable-track-vars --enable-sysvsem \
--enable-sysvshm --enable-inline-optimization \
--with-curl --with-regex=system --with-png \
--enable-discard-path --enable-dbx --enable-memory-limit \
--disable-debug --disable-rpath --with-openssl \
--enable-exif --enable-mbstring  \
--with-xsl=/usr/lib \
--with-milter --disable-cli --disable-cgi --enable-debug

and launching the example milter I was getting the memory leaks warnings
below.

-
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(304) :  Freeing
0xA5E46184 (44 bytes), script=-
/usr/local/php5.2-200702061930/Zend/zend_API.c(819) : Actual location
(location was relayed)
Last leak repeated 1 time
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(196) :  Freeing
0xA5E464
70 (10 bytes), script=-
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(346) :  Freeing
0xA5E466
C4 (3 bytes), script=-
Last leak repeated 5 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/Zend/zend_API.c(1193) :  Freeing 0xA5E466F8
(16 bytes), script=-
Last leak repeated 2 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(229) :  Freeing
0xA5E468A8 (10 bytes), script=-
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/Zend/zend_API.c(1194) :  Freeing 0xA5E468E4
(17 bytes), script=-
Last leak repeated 2 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/Zend/zend_API.c(1196) :  Freeing 0xA5E46958
(35 bytes), script=-
/usr/local/php5.2-200702061930/Zend/zend_hash.c(388) : Actual location
(location was relayed)
Last leak repeated 2 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(411) :  Freeing
0xA5E46E
D8 (43 bytes), script=-
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(347) :  Freeing
0xA5E470
50 (40 bytes), script=-
Last leak repeated 5 times
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(264) :  Freeing
0xA5E49A
58 (32 bytes), script=-
/usr/local/php5.2-200702061930/Zend/zend_alloc.c(1917) : Actual location
(location was relayed)
Last leak repeated 1 time
[Wed Feb  7 10:20:03 2007]  Script:  '-'
/usr/local/php5.2-200702061930/sapi/milter/php_milter.c(192) :  Freeing
0xA5E505E8 (16 bytes), script=-
=== Total 29 memory leaks detected ===
---


The TODO file in the distribution mention such leaks.



Reproduce code:
---
the milter.php in the milter sapi distribution 

Expected result:

no memory leaks

Actual result:
--
a lot of memory leaks warnings.

-- 
Edit bug report at http://bugs.php.net/?id=40392&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40392&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40392&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40392&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40392&r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=40392&r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=40392&r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=40392&r=needscript
Try newer version:http://bugs.php.net/fix.php?id=40392&r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=40392&r=support
Expected behavior:http://bugs.php.net/fix.php?id=40392&r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=40392&r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=40392&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40392&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40392&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40392&r=dst
IIS Stability:http://bugs.php.net/fix.php?id=40392&r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=40392&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40392&r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=40392&r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=40392&r=mysqlcfg


#40083 [Fbk->Opn]: in the milter SAPI, the function smfi_getsymval always returns blank strings

2007-01-10 Thread tuxracer69 at gmail dot com
 ID:   40083
 User updated by:  tuxracer69 at gmail dot com
 Reported By:  tuxracer69 at gmail dot com
-Status:   Feedback
+Status:   Open
 Bug Type: Unknown/Other Function
 Operating System: Linux debi 2.6.17-2-k7 #1 SMP Fr
 PHP Version:  5.2.0
 New Comment:

Hi Tony,

I saw you replaced the string
RETVAL_
by the string
RETURN_

in the php_milter.c code.

And I confirm that works *fine* now.
Thank you.

--
Please, please, please, do not remove the SAPI from the distribution.
Leaving it as 'experimental' is OK but removing it would be a drama.
With that many spam on the Internet, it is *so* cool to be able to use
our favorite programming language to fight spam or manipulate mails!
Please don't force me to use C or Perl to talk to sendmail ;)(Even so
there is  huge amount of work done with Perl).

I think the SAPI code is relatively small, so not not complicated to
maintain. As so many programs already depend on the sendmail milter
API, we can hope they won't change it soon.

We, the user base, will keep reporting the bugs we find to keep this
part of the code up to date.

I will also try to publish some tutorials on the Internet to let people
know about this SAPI.

Thanks again for your help and the very fast fix.


Previous Comments:


[2007-01-10 12:04:27] [EMAIL PROTECTED]

Please try the next snapshot from http://snaps.php.net, it should be
fixed there.
(Though I would not recommend using this SAPI, as it's unmaintained for
a long time).

----

[2007-01-10 11:58:38] tuxracer69 at gmail dot com

Hi Iliia,

I confirm it is  bug in PHP and I even provide a fix below ;)
and thus reopen this bug.
In the file  
PHPROOT/sapi/milter/php_milter.c
the last line in the function 
PHP_FUNCTION(smfi_getsymval)
 (i.e. the line
   RETVAL_NULL();
) seems to be always called and thus the function when called in PHP
always return NULL.
Although I am not a SAPI expert (nor a C expert BTW) and thus do not
understand why it is always called, removing this line and considering
each case fixes the bug.

Iliia could you please confirm this?
Thanks
Alex


 here is an example of code fixing the bug ==

PHP_FUNCTION(smfi_getsymval)
{
char *symname, *ret;
int len;

/* valid in any callback */
if (MG(state) == MLFI_NONE) {
/*php_error(E_WARNING, IS_NONE,
get_active_function_name(TSRMLS_C));*/
RETVAL_STRING("MLFI_NONE", 1);
} else {
if (zend_parse_parameters(1 TSRMLS_CC, "s", &symname,
&len) == SUCCESS) {
if ((ret = smfi_getsymval(MG(ctx), symname)) !=
NULL) {
   RETVAL_STRING(ret, 1);
} else {
 RETVAL_STRING("isnull", 1);
}
} else {
RETVAL_STRING("zend_parse_parameters returned FAILURE",
1);
}
}

}


Note that if I just add again the line 
RETVAL_NULL();
at the bottom of the function above, I will again get a NULL string all
the time.



[2007-01-10 03:52:03] [EMAIL PROTECTED]

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The function is a direct wrapper around smfi_getsymval() 
milter function. So the fact it does not return anything can 
be traced directly to milter and not PHP.

--------------------

[2007-01-09 20:51:26] tuxracer69 at gmail dot com

Description:

The milter SAPI seems unable to get the values of the sendmail macros
using the smfi_getsymval function.

My steup:
0) I compile PHP with "--with-milter --disable-cli --disable-cgi"
1) I create a script milter1.php (code below)
2) I insert in my /etc/mail/sendmail.mc the two lines below:
==
define(`MILTER',`1')dnl
INPUT_MAIL_FILTER(`php-milter1',`S=local:/tmp/milter.sock,F=T,T=S:10m;R:10m;E:10m')dnl
==
3) I start the milter with:
php-milter -D -p /tmp/milter.sock milter1.php
4) I forge a mail to localhot using telnet to port 25
5) I look at the milter logs which shoud display the vaue of the "i"
sendmail macro (the sendmail queueid). 

Reproduce code:
---
 $arg) {
milter_log("\targs[$ix] = $arg");
}
}
?>


Expected result:

#40083 [Bgs->Opn]: in the milter SAPI, the function smfi_getsymval always returns blank strings

2007-01-10 Thread tuxracer69 at gmail dot com
 ID:   40083
 User updated by:  tuxracer69 at gmail dot com
 Reported By:  tuxracer69 at gmail dot com
-Status:   Bogus
+Status:   Open
 Bug Type: Unknown/Other Function
 Operating System: Linux debi 2.6.17-2-k7 #1 SMP Fr
 PHP Version:  5.2.0
 New Comment:

Hi Iliia,

I confirm it is  bug in PHP and I even provide a fix below ;)
and thus reopen this bug.
In the file  
PHPROOT/sapi/milter/php_milter.c
the last line in the function 
PHP_FUNCTION(smfi_getsymval)
 (i.e. the line
   RETVAL_NULL();
) seems to be always called and thus the function when called in PHP
always return NULL.
Although I am not a SAPI expert (nor a C expert BTW) and thus do not
understand why it is always called, removing this line and considering
each case fixes the bug.

Iliia could you please confirm this?
Thanks
Alex


 here is an example of code fixing the bug ==

PHP_FUNCTION(smfi_getsymval)
{
char *symname, *ret;
int len;

/* valid in any callback */
if (MG(state) == MLFI_NONE) {
/*php_error(E_WARNING, IS_NONE,
get_active_function_name(TSRMLS_C));*/
RETVAL_STRING("MLFI_NONE", 1);
} else {
if (zend_parse_parameters(1 TSRMLS_CC, "s", &symname,
&len) == SUCCESS) {
if ((ret = smfi_getsymval(MG(ctx), symname)) !=
NULL) {
   RETVAL_STRING(ret, 1);
} else {
 RETVAL_STRING("isnull", 1);
}
} else {
RETVAL_STRING("zend_parse_parameters returned FAILURE",
1);
}
}

}


Note that if I just add again the line 
RETVAL_NULL();
at the bottom of the function above, I will again get a NULL string all
the time.


Previous Comments:


[2007-01-10 03:52:03] [EMAIL PROTECTED]

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The function is a direct wrapper around smfi_getsymval() 
milter function. So the fact it does not return anything can 
be traced directly to milter and not PHP.

------------

[2007-01-09 20:51:26] tuxracer69 at gmail dot com

Description:

The milter SAPI seems unable to get the values of the sendmail macros
using the smfi_getsymval function.

My steup:
0) I compile PHP with "--with-milter --disable-cli --disable-cgi"
1) I create a script milter1.php (code below)
2) I insert in my /etc/mail/sendmail.mc the two lines below:
==
define(`MILTER',`1')dnl
INPUT_MAIL_FILTER(`php-milter1',`S=local:/tmp/milter.sock,F=T,T=S:10m;R:10m;E:10m')dnl
==
3) I start the milter with:
php-milter -D -p /tmp/milter.sock milter1.php
4) I forge a mail to localhot using telnet to port 25
5) I look at the milter logs which shoud display the vaue of the "i"
sendmail macro (the sendmail queueid). 

Reproduce code:
---
 $arg) {
milter_log("\targs[$ix] = $arg");
}
}
?>


Expected result:

After having started the milter:

# php-milter -D -p /tmp/milter.sock milter1.php

I forge a mail:

# telnet localhost 25
Trying 127.0.0.1...
Connected to debi.
Escape character is '^]'.
220 debi.local. ESMTP Sendmail 8.13.7/8.13.7/Debian-2; Tue, 9 Jan 2007
21:25:35 +0100; (No UCE/UBE) logging access from: debi(OK)-debi
[127.0.0.1]
helo me
250 debi.local. Hello debi [127.0.0.1], pleased to meet you
mail from: [EMAIL PROTECTED]
250 2.1.0 [EMAIL PROTECTED] Sender ok
quit
221 2.0.0 debi.local. closing connection
Connection closed by foreign host.

I get the queueid from the sendmail logs:
# tail -n 1 /var/log/mail.log
Jan  9 21:25:55 debi sm-mta[14429]: l09KPZRk014429:
[EMAIL PROTECTED], size=0, class=0, nrcpts=0, proto=SMTP,
daemon=MTA-v4, relay=debi [127.0.0.1]

And a  would expect a line in the milter logs saying

[21:25:49 09.01.2007] p14426queueid=l09KPZRk014429

But (see below the logs I get),  I can not get any value for the "i"
macro.
I am sure it is set. If I strace -v -f the milter I see the queueid in
a read system call.

Actual result:
--
The third line in the milter logs shows a blank queueid

tail -f /var/log/milter.log
[21:25:26 09.01.2007] p14426-- startup --
[21:25:26 09.01.2007] p14426milter_init()
[21:25:49 09.01.2007] p14426queueid=
[21:25:49 09.01.2007] p14426milter_envfrom(args[])
[21:25:49 09.01.2007] p14426 

#40083 [NEW]: in the milter SAPI, the function smfi_getsymval always returns blank strings

2007-01-09 Thread tuxracer69 at gmail dot com
From: tuxracer69 at gmail dot com
Operating system: Linux debi 2.6.17-2-k7 #1 SMP Fr
PHP version:  5.2.0
PHP Bug Type: Unknown/Other Function
Bug description:  in the milter SAPI, the function smfi_getsymval always 
returns blank strings

Description:

The milter SAPI seems unable to get the values of the sendmail macros
using the smfi_getsymval function.

My steup:
0) I compile PHP with "--with-milter --disable-cli --disable-cgi"
1) I create a script milter1.php (code below)
2) I insert in my /etc/mail/sendmail.mc the two lines below:
==
define(`MILTER',`1')dnl
INPUT_MAIL_FILTER(`php-milter1',`S=local:/tmp/milter.sock,F=T,T=S:10m;R:10m;E:10m')dnl
==
3) I start the milter with:
php-milter -D -p /tmp/milter.sock milter1.php
4) I forge a mail to localhot using telnet to port 25
5) I look at the milter logs which shoud display the vaue of the "i"
sendmail macro (the sendmail queueid). 

Reproduce code:
---
 $arg) {
milter_log("\targs[$ix] = $arg");
}
}
?>


Expected result:

After having started the milter:

# php-milter -D -p /tmp/milter.sock milter1.php

I forge a mail:

# telnet localhost 25
Trying 127.0.0.1...
Connected to debi.
Escape character is '^]'.
220 debi.local. ESMTP Sendmail 8.13.7/8.13.7/Debian-2; Tue, 9 Jan 2007
21:25:35 +0100; (No UCE/UBE) logging access from: debi(OK)-debi
[127.0.0.1]
helo me
250 debi.local. Hello debi [127.0.0.1], pleased to meet you
mail from: [EMAIL PROTECTED]
250 2.1.0 [EMAIL PROTECTED] Sender ok
quit
221 2.0.0 debi.local. closing connection
Connection closed by foreign host.

I get the queueid from the sendmail logs:
# tail -n 1 /var/log/mail.log
Jan  9 21:25:55 debi sm-mta[14429]: l09KPZRk014429: [EMAIL PROTECTED],
size=0, class=0, nrcpts=0, proto=SMTP, daemon=MTA-v4, relay=debi
[127.0.0.1]

And a  would expect a line in the milter logs saying

[21:25:49 09.01.2007] p14426queueid=l09KPZRk014429

But (see below the logs I get),  I can not get any value for the "i"
macro.
I am sure it is set. If I strace -v -f the milter I see the queueid in a
read system call.

Actual result:
--
The third line in the milter logs shows a blank queueid

tail -f /var/log/milter.log
[21:25:26 09.01.2007] p14426-- startup --
[21:25:26 09.01.2007] p14426milter_init()
[21:25:49 09.01.2007] p14426queueid=
[21:25:49 09.01.2007] p14426milter_envfrom(args[])
[21:25:49 09.01.2007] p14426args[0] = [EMAIL PROTECTED]


I tried to modify my PHP code and call the macro "{i}" but it does not
help.


I would say it is a PHP bug and not a sendmail bug; here is my sendmail
version anyway:
# sendmail -d0.1
Version 8.13.7
 Compiled with: DNSMAP LDAPMAP LDAP_REFERRALS LOG MAP_REGEX MATCHGECOS
MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
NETUNIX
NEWDB NIS NISPLUS PIPELINING SASLv2 SCANF SOCKETMAP
STARTTLS
USERDB USE_LDAP_INIT XDEBUG

 SYSTEM IDENTITY (after readcf) 
  (short domain name) $w = debi
  (canonical domain name) $j = debi.local.
 (subdomain name) $m = local.
  (node name) $k = debi




-- 
Edit bug report at http://bugs.php.net/?id=40083&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40083&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40083&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40083&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40083&r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=40083&r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=40083&r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=40083&r=needscript
Try newer version:http://bugs.php.net/fix.php?id=40083&r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=40083&r=support
Expected behavior:http://bugs.php.net/fix.php?id=40083&r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=40083&r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=40083&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40083&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40083&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40083&r=dst
IIS Stability:http://bugs.php.net/fix.php?id=40083&r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=40083&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40083&r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=40083&r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=40083&r=mysqlcfg