diff options
author | Sebastian Ramadan <plebbyastian@gmail.com> | 2017-12-17 00:21:47 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-12-17 00:24:45 +0100 |
commit | 168c6cda8f906b72025f9cd9aadad48553dd5764 (patch) | |
tree | 372f68df86556dba7c04903d1c4e9a3e5f4498f4 /sapi/phpdbg/phpdbg_rinit_hook.c | |
parent | e835e3c1324bd5e285afd8403f7554c7a2fe3f4f (diff) | |
download | php-git-168c6cda8f906b72025f9cd9aadad48553dd5764.tar.gz |
Transmit phpdbg webdata len in little-endian
Rather than using machine-endianness through a UB cast.
Diffstat (limited to 'sapi/phpdbg/phpdbg_rinit_hook.c')
-rw-r--r-- | sapi/phpdbg/phpdbg_rinit_hook.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sapi/phpdbg/phpdbg_rinit_hook.c b/sapi/phpdbg/phpdbg_rinit_hook.c index 667f32ea1a..c62b272a16 100644 --- a/sapi/phpdbg/phpdbg_rinit_hook.c +++ b/sapi/phpdbg/phpdbg_rinit_hook.c @@ -56,9 +56,9 @@ static PHP_RINIT_FUNCTION(phpdbg_webhelper) /* {{{ */ { struct sockaddr_un sock; int s = socket(AF_UNIX, SOCK_STREAM, 0); - int len = strlen(PHPDBG_WG(path)) + sizeof(sock.sun_family); + size_t len = strlen(PHPDBG_WG(path)) + sizeof(sock.sun_family); char buf[(1 << 8) + 1]; - int buflen; + ssize_t buflen; sock.sun_family = AF_UNIX; strcpy(sock.sun_path, PHPDBG_WG(path)); @@ -67,11 +67,15 @@ static PHP_RINIT_FUNCTION(phpdbg_webhelper) /* {{{ */ } char *msg = NULL; - char msglen[5] = {0}; - phpdbg_webdata_compress(&msg, (int *)msglen); - - send(s, msglen, 4, 0); - send(s, msg, *(int *) msglen, 0); + size_t msglen = 0; + phpdbg_webdata_compress(&msg, &msglen); + + buf[0] = (msglen >> 0) & 0xff; + buf[1] = (msglen >> 8) & 0xff; + buf[2] = (msglen >> 16) & 0xff; + buf[3] = (msglen >> 24) & 0xff; + send(s, buf, 4, 0); + send(s, msg, msglen, 0); while ((buflen = recv(s, buf, sizeof(buf) - 1, 0)) > 0) { php_write(buf, buflen); |