From: Nikita Popov Date: Mon, 3 Aug 2020 12:55:18 +0000 (+0200) Subject: Fix bug #79924 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b4da1774f2e8ba74579675460c37e0ebe723fdc;p=php Fix bug #79924 Move functions that are only used with ipv6 support under HAVE_IPV6 checks. --- diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index b7dae45407..927e16ff95 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -499,34 +499,36 @@ void to_zval_read_int(const char *data, zval *zv, res_context *ctx) ZVAL_LONG(zv, (zend_long)ival); } -static void to_zval_read_unsigned(const char *data, zval *zv, res_context *ctx) +static void to_zval_read_net_uint16(const char *data, zval *zv, res_context *ctx) { - unsigned ival; + uint16_t ival; memcpy(&ival, data, sizeof(ival)); - ZVAL_LONG(zv, (zend_long)ival); + ZVAL_LONG(zv, (zend_long)ntohs(ival)); } -static void to_zval_read_net_uint16(const char *data, zval *zv, res_context *ctx) +static void to_zval_read_sa_family(const char *data, zval *zv, res_context *ctx) { - uint16_t ival; + sa_family_t ival; memcpy(&ival, data, sizeof(ival)); - ZVAL_LONG(zv, (zend_long)ntohs(ival)); + ZVAL_LONG(zv, (zend_long)ival); } -static void to_zval_read_uint32(const char *data, zval *zv, res_context *ctx) +#if HAVE_IPV6 +static void to_zval_read_unsigned(const char *data, zval *zv, res_context *ctx) { - uint32_t ival; + unsigned ival; memcpy(&ival, data, sizeof(ival)); ZVAL_LONG(zv, (zend_long)ival); } -static void to_zval_read_sa_family(const char *data, zval *zv, res_context *ctx) +static void to_zval_read_uint32(const char *data, zval *zv, res_context *ctx) { - sa_family_t ival; + uint32_t ival; memcpy(&ival, data, sizeof(ival)); ZVAL_LONG(zv, (zend_long)ival); } +#endif #ifdef SO_PASSCRED static void to_zval_read_pid_t(const char *data, zval *zv, res_context *ctx) { @@ -1232,6 +1234,7 @@ void to_zval_read_msghdr(const char *msghdr_c, zval *zv, res_context *ctx) to_zval_read_aggregation(msghdr_c, zv, descriptors, ctx); } +#if defined(IPV6_PKTINFO) && HAVE_IPV6 /* CONVERSIONS for if_index */ static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context *ctx) { @@ -1288,7 +1291,6 @@ static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context } /* CONVERSIONS for struct in6_pktinfo */ -#if defined(IPV6_PKTINFO) && HAVE_IPV6 static const field_descriptor descriptors_in6_pktinfo[] = { {"addr", sizeof("addr"), 1, offsetof(struct in6_pktinfo, ipi6_addr), from_zval_write_sin6_addr, to_zval_read_sin6_addr}, {"ifindex", sizeof("ifindex"), 1, offsetof(struct in6_pktinfo, ipi6_ifindex), from_zval_write_ifindex, to_zval_read_unsigned},