]> granicus.if.org Git - php/commitdiff
Revert "Payload of HOPLIMIT/TCLASS are 8-bit"
authorGustavo Lopes <glopes@nebm.ist.utl.pt>
Thu, 31 Jan 2013 14:26:10 +0000 (15:26 +0100)
committerGustavo Lopes <glopes@nebm.ist.utl.pt>
Sat, 2 Feb 2013 15:38:08 +0000 (16:38 +0100)
This reverts commit 61a5ec7381ba5388a52926779fe3f58af0caea83.

I checked Linux and OpenBSD and both use integers to write the
IPV6_TCLASS messages and they don't force any endianness. This is
despite RFC 3542 explicitly saying the first byte of cmsg_data will
have the result. In any case, it doesn't make any difference in
little-endian archs.

ext/sockets/conversions.c
ext/sockets/conversions.h
ext/sockets/sendrecvmsg.c

index d0d0c4b798651fc3aa1fbac66e0905bd456c341b..fa6d94948678db75c593b665ced8c2878e39b1e4 100644 (file)
@@ -317,7 +317,7 @@ double_case:
 
        return ret;
 }
-static void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx)
+void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx)
 {
        long lval;
        int ival;
@@ -355,25 +355,6 @@ static void from_zval_write_uint32(const zval *arr_value, char *field, ser_conte
        ival = (uint32_t)lval;
        memcpy(field, &ival, sizeof(ival));
 }
-void from_zval_write_uint8(const zval *arr_value, char *field, ser_context *ctx)
-{
-       long lval;
-       uint8_t ival;
-
-       lval = from_zval_integer_common(arr_value, ctx);
-       if (ctx->err.has_error) {
-               return;
-       }
-
-       if (lval < 0 || lval > 0xFF) {
-               do_from_zval_err(ctx, "%s", "given PHP integer is out of bounds "
-                               "for an unsigned 8-bit integer");
-               return;
-       }
-
-       ival = (uint8_t)lval;
-       memcpy(field, &ival, sizeof(ival));
-}
 static void from_zval_write_net_uint16(const zval *arr_value, char *field, ser_context *ctx)
 {
        long lval;
@@ -460,7 +441,7 @@ static void from_zval_write_uid_t(const zval *arr_value, char *field, ser_contex
        memcpy(field, &ival, sizeof(ival));
 }
 
-static void to_zval_read_int(const char *data, zval *zv, res_context *ctx)
+void to_zval_read_int(const char *data, zval *zv, res_context *ctx)
 {
        int ival;
        memcpy(&ival, data, sizeof(ival));
@@ -474,13 +455,6 @@ static void to_zval_read_unsigned(const char *data, zval *zv, res_context *ctx)
 
        ZVAL_LONG(zv, (long)ival);
 }
-void to_zval_read_uint8(const char *data, zval *zv, res_context *ctx)
-{
-       uint8_t ival;
-       memcpy(&ival, data, sizeof(ival));
-
-       ZVAL_LONG(zv, (long)ival);
-}
 static void to_zval_read_net_uint16(const char *data, zval *zv, res_context *ctx)
 {
        uint16_t ival;
index 79ca4ab76e27127ea118de443e1924fa7cc0d0fb..70f31ba676e561778c73a10b4dd83c1efc006d29 100644 (file)
@@ -37,8 +37,8 @@ void err_msg_dispose(struct err_s *err TSRMLS_DC);
 void allocations_dispose(zend_llist **allocations);
 
 /* CONVERSION FUNCTIONS */
-void from_zval_write_uint8(const zval *arr_value, char *field, ser_context *ctx);
-void to_zval_read_uint8(const char *data, zval *zv, res_context *ctx);
+void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx);
+void to_zval_read_int(const char *data, zval *zv, res_context *ctx);
 
 #ifdef IPV6_PKTINFO
 void from_zval_write_in6_pktinfo(const zval *container, char *in6_pktinfo_c, ser_context *ctx);
index f325b0378a9430995ec0a7dfe5b4e19deb2a6127..b83b3ae48237824acb6ac3db995eac2c2234a784 100644 (file)
@@ -73,14 +73,12 @@ static void init_ancillary_registry(void)
 #endif
 
 #ifdef IPV6_HOPLIMIT
-       PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_uint8,
-                       to_zval_read_uint8, IPPROTO_IPV6, IPV6_HOPLIMIT);
+       PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int,
+                       to_zval_read_int, IPPROTO_IPV6, IPV6_HOPLIMIT);
 #endif
 
-#ifdef IPV6_TCLASS
-       PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_uint8,
-                       to_zval_read_uint8, IPPROTO_IPV6, IPV6_TCLASS);
-#endif
+       PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int,
+                       to_zval_read_int, IPPROTO_IPV6, IPV6_TCLASS);
 
 #ifdef SO_PASSCRED
        PUT_ENTRY(sizeof(struct ucred), 0, 0, from_zval_write_ucred,