php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #63293
Patch add-column-to-unixsocket revision 2012-10-16 19:14 UTC by samm at os2 dot kiev dot ua

Patch add-column-to-unixsocket for Streams related Bug #63293

Patch version 2012-10-16 19:14 UTC

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

Developer: samm@os2.kiev.ua

diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index 7c3a553..5304531 100644
--- a/main/streams/xp_socket.c
+++ b/main/streams/xp_socket.c
@@ -498,6 +498,9 @@ php_stream_ops php_stream_unixdg_socket_ops = {
 #ifdef AF_UNIX
 static inline int parse_unix_address(php_stream_xport_param *xparam, struct sockaddr_un *unix_addr TSRMLS_DC)
 {
+	char *colon;
+	char *socketstr = NULL;
+
 	memset(unix_addr, 0, sizeof(*unix_addr));
 	unix_addr->sun_family = AF_UNIX;
 
@@ -515,8 +518,17 @@ static inline int parse_unix_address(php_stream_xport_param *xparam, struct sock
 			"and was truncated", (unsigned long)sizeof(unix_addr->sun_path));
 	}
 
-	memcpy(unix_addr->sun_path, xparam->inputs.name, xparam->inputs.namelen);
-
+	if (xparam->inputs.namelen) {
+		colon = memchr(xparam->inputs.name, ':', xparam->inputs.namelen - 1);
+	} else {
+		colon = NULL;
+	}
+	if (colon) {
+		socketstr = estrndup(xparam->inputs.name, colon - xparam->inputs.name);
+		memcpy(unix_addr->sun_path, socketstr, strlen(socketstr));
+	} else {
+	    memcpy(unix_addr->sun_path, xparam->inputs.name, xparam->inputs.namelen);
+	}
 	return 1;
 }
 #endif
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 18:01:29 2024 UTC