php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #51459
Patch milter_connect_ipaddr revision 2010-04-02 15:14 UTC by steven at etrafficers dot com
revision 2010-04-01 21:44 UTC by steven at etrafficers dot com

Patch milter_connect_ipaddr for Other web server Bug #51459

Patch version 2010-04-02 15:14 UTC

Return to Bug #51459 | Download this patch
Patch Revisions:

Developer: steven@etrafficers.com

--- php_milter.c	2010-01-03 09:23:27.000000000 +0000
+++ ../../../../php-5.3.2/sapi/milter/php_milter.c	2010-04-01 21:00:00.000000000 +0000
@@ -172,7 +172,7 @@
 static sfsistat	mlfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr)
 {
 	zend_file_handle file_handle;
-	zval function_name, retval, *param[1];
+	zval function_name, retval, *param[2];
 	int status;
 	TSRMLS_FETCH();
 
@@ -205,16 +205,40 @@
 	INIT_ZVAL(function_name);
 
 	ALLOC_ZVAL(param[0]);
+	ALLOC_ZVAL(param[1]);
 	INIT_PZVAL(param[0]);
+	INIT_PZVAL(param[1]);
 
 	ZVAL_STRING(&function_name, "milter_connect", 0);
 	ZVAL_STRING(param[0], hostname, 1);
+	if(hostaddr)
+		{
+		char ipaddr[64];
+		switch(hostaddr->sa_family){
+			case AF_INET:	{
+							struct sockaddr_in *sin = (struct sockaddr_in *)hostaddr;
+							inet_ntop(AF_INET, &sin->sin_addr.s_addr,ipaddr,sizeof(ipaddr));
+							ZVAL_STRING(param[1], ipaddr, 1); 
+							break;
+							}	
+			case AF_INET6:	{
+							struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)hostaddr;
+							inet_ntop(AF_INET6, &sin6->sin6_addr, ipaddr, sizeof(ipaddr));
+							ZVAL_STRING(param[1], ipaddr, 1); 
+							break;
+							}
+			}
+		}
+	else
+		{
+		ZVAL_STRING(param[1],"non_inet", 1);
+		}
 
 	/* set the milter context for possible use in API functions */
 	MG(ctx) = ctx;
 	MG(state) = MLFI_CONNECT;
 
-	status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param TSRMLS_CC);
+	status = call_user_function(CG(function_table), NULL, &function_name, &retval, 2, param TSRMLS_CC);
 
 	MG(state) = MLFI_NONE;
 	zval_ptr_dtor(param);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 04 09:01:27 2024 UTC