com php-src: Transmit phpdbg webdata len in little-endian: sapi/phpdbg/phpdbg_rinit_hook.c sapi/phpdbg/phpdbg_we bdata_transfer.c
sapi/phpdbg/phpdbg_webdata_transfer .h
| From: | Nikita Popov | Date: | Sat, 16 Dec 2017 23:24:45 +0000 |
| Subject: | com php-src: Transmit phpdbg webdata len in little-endian: sapi/phpdbg/phpdbg_rinit_hook.c sapi/phpdbg/phpdbg_we bdata_transfer.c sapi/phpdbg/phpdbg_webdata_transfer .h |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100623@lists.php.net to get a copy of this message | ||
Commit: 168c6cda8f906b72025f9cd9aadad48553dd5764
Author: Sebastian Ramadan <plebbyastian@gmail.com> Sun, 17 Dec 2017 00:21:47 +0100
Committer: Nikita Popov <nikita.ppv@gmail.com> Sun, 17 Dec 2017 00:24:45 +0100
Parents: e835e3c1324bd5e285afd8403f7554c7a2fe3f4f
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=168c6cda8f906b72025f9cd9aadad48553dd5764
Log:
Transmit phpdbg webdata len in little-endian
Rather than using machine-endianness through a UB cast.
Changed paths:
M sapi/phpdbg/phpdbg_rinit_hook.c
M sapi/phpdbg/phpdbg_webdata_transfer.c
M sapi/phpdbg/phpdbg_webdata_transfer.h
Diff:
diff --git a/sapi/phpdbg/phpdbg_rinit_hook.c b/sapi/phpdbg/phpdbg_rinit_hook.c
index 667f32e..c62b272 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);
diff --git a/sapi/phpdbg/phpdbg_webdata_transfer.c b/sapi/phpdbg/phpdbg_webdata_transfer.c
index 411ee92..5cb6ea4 100644
--- a/sapi/phpdbg/phpdbg_webdata_transfer.c
+++ b/sapi/phpdbg/phpdbg_webdata_transfer.c
@@ -27,7 +27,7 @@ static int phpdbg_is_auto_global(char *name, int len) {
return ret;
}
-PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len) {
+PHPDBG_API void phpdbg_webdata_compress(char **msg, size_t *len) {
zval array;
HashTable *ht;
zval zv[9] = {{{0}}};
diff --git a/sapi/phpdbg/phpdbg_webdata_transfer.h b/sapi/phpdbg/phpdbg_webdata_transfer.h
index b8da8c1..b8473d3 100644
--- a/sapi/phpdbg/phpdbg_webdata_transfer.h
+++ b/sapi/phpdbg/phpdbg_webdata_transfer.h
@@ -22,6 +22,6 @@
#include "zend.h"
#include "phpdbg.h"
-PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len);
+PHPDBG_API void phpdbg_webdata_compress(char **msg, size_t *len);
#endif /* PHPDBG_WEBDATA_TRANSFER_H */