diff options
Diffstat (limited to 'ext/sockets/conversions.c')
-rw-r--r-- | ext/sockets/conversions.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index 1f7d3e8766..c8acaf6995 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -159,8 +159,8 @@ static void do_from_to_zval_err(struct err_s *err, smart_str_appends(&path, " > "); } - if (path.s && path.s->len > 3) { - path.s->len -= 3; + if (path.s && ZSTR_LEN(path.s) > 3) { + ZSTR_LEN(path.s) -= 3; } smart_str_0(&path); @@ -170,7 +170,7 @@ static void do_from_to_zval_err(struct err_s *err, err->level = E_WARNING; spprintf(&err->msg, 0, "error converting %s data (path: %s): %.*s", what_conv, - path.s && *path.s->val != '\0' ? path.s->val : "unavailable", + path.s && *ZSTR_VAL(path.s) != '\0' ? ZSTR_VAL(path.s) : "unavailable", user_msg_size, user_msg); err->should_free = 1; @@ -544,13 +544,13 @@ static void from_zval_write_sin_addr(const zval *zaddr_str, char *inaddr, ser_co zend_string *addr_str; addr_str = zval_get_string((zval *) zaddr_str); - res = php_set_inet_addr(&saddr, addr_str->val, ctx->sock); + res = php_set_inet_addr(&saddr, ZSTR_VAL(addr_str), ctx->sock); if (res) { memcpy(inaddr, &saddr.sin_addr, sizeof saddr.sin_addr); } else { /* error already emitted, but let's emit another more relevant */ do_from_zval_err(ctx, "could not resolve address '%s' to get an AF_INET " - "address", addr_str->val); + "address", ZSTR_VAL(addr_str)); } zend_string_release(addr_str); @@ -560,7 +560,7 @@ static void to_zval_read_sin_addr(const char *data, zval *zv, res_context *ctx) const struct in_addr *addr = (const struct in_addr *)data; socklen_t size = INET_ADDRSTRLEN; zend_string *str = zend_string_alloc(size - 1, 0); - memset(str->val, '\0', size); + memset(ZSTR_VAL(str), '\0', size); ZVAL_NEW_STR(zv, str); @@ -594,7 +594,7 @@ static void from_zval_write_sin6_addr(const zval *zaddr_str, char *addr6, ser_co zend_string *addr_str; addr_str = zval_get_string((zval *) zaddr_str); - res = php_set_inet6_addr(&saddr6, addr_str->val, ctx->sock); + res = php_set_inet6_addr(&saddr6, ZSTR_VAL(addr_str), ctx->sock); if (res) { memcpy(addr6, &saddr6.sin6_addr, sizeof saddr6.sin6_addr); } else { @@ -611,7 +611,7 @@ static void to_zval_read_sin6_addr(const char *data, zval *zv, res_context *ctx) socklen_t size = INET6_ADDRSTRLEN; zend_string *str = zend_string_alloc(size - 1, 0); - memset(str->val, '\0', size); + memset(ZSTR_VAL(str), '\0', size); ZVAL_NEW_STR(zv, str); @@ -650,18 +650,18 @@ static void from_zval_write_sun_path(const zval *path, char *sockaddr_un_c, ser_ /* code in this file relies on the path being nul terminated, even though * this is not required, at least on linux for abstract paths. It also * assumes that the path is not empty */ - if (path_str->len == 0) { + if (ZSTR_LEN(path_str) == 0) { do_from_zval_err(ctx, "%s", "the path is cannot be empty"); return; } - if (path_str->len >= sizeof(saddr->sun_path)) { + if (ZSTR_LEN(path_str) >= sizeof(saddr->sun_path)) { do_from_zval_err(ctx, "the path is too long, the maximum permitted " "length is %ld", sizeof(saddr->sun_path) - 1); return; } - memcpy(&saddr->sun_path, path_str->val, path_str->len); - saddr->sun_path[path_str->len] = '\0'; + memcpy(&saddr->sun_path, ZSTR_VAL(path_str), ZSTR_LEN(path_str)); + saddr->sun_path[ZSTR_LEN(path_str)] = '\0'; zend_string_release(path_str); } @@ -1207,8 +1207,8 @@ static void to_zval_read_iov(const char *msghdr_c, zval *zv, res_context *ctx) size_t len = MIN(msghdr->msg_iov[i].iov_len, (size_t)bytes_left); zend_string *buf = zend_string_alloc(len, 0); - memcpy(buf->val, msghdr->msg_iov[i].iov_base, buf->len); - buf->val[buf->len] = '\0'; + memcpy(ZSTR_VAL(buf), msghdr->msg_iov[i].iov_base, ZSTR_LEN(buf)); + ZSTR_VAL(buf)[ZSTR_LEN(buf)] = '\0'; ZVAL_NEW_STR(&elem, buf); add_next_index_zval(zv, &elem); @@ -1248,24 +1248,24 @@ static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context str = zval_get_string((zval *) zv); #if HAVE_IF_NAMETOINDEX - ret = if_nametoindex(str->val); + ret = if_nametoindex(ZSTR_VAL(str)); if (ret == 0) { - do_from_zval_err(ctx, "no interface with name \"%s\" could be found", str->val); + do_from_zval_err(ctx, "no interface with name \"%s\" could be found", ZSTR_VAL(str)); } #elif defined(SIOCGIFINDEX) { struct ifreq ifr; - if (strlcpy(ifr.ifr_name, str->val, sizeof(ifr.ifr_name)) + if (strlcpy(ifr.ifr_name, ZSTR_VAL(str), sizeof(ifr.ifr_name)) >= sizeof(ifr.ifr_name)) { - do_from_zval_err(ctx, "the interface name \"%s\" is too large ", str->val); + do_from_zval_err(ctx, "the interface name \"%s\" is too large ", ZSTR_VAL(str)); } else if (ioctl(ctx->sock->bsd_socket, SIOCGIFINDEX, &ifr) < 0) { if (errno == ENODEV) { do_from_zval_err(ctx, "no interface with name \"%s\" could be " - "found", str->val); + "found", ZSTR_VAL(str)); } else { do_from_zval_err(ctx, "error fetching interface index for " "interface with name \"%s\" (errno %d)", - str->val, errno); + ZSTR_VAL(str), errno); } } else { ret = (unsigned)ifr.ifr_ifindex; |