Skip to content

Commit 4a96aa9

Browse files
committed
Try to fix windows build
1 parent c73bb45 commit 4a96aa9

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

ext/ip_extraction.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ DDTRACE_PUBLIC zend_string *ddtrace_ip_extraction_find(zval *server) {
137137
}
138138

139139
ipaddr out;
140-
__auto_type res = dd_parse_forwarded(value, &out);
140+
struct extract_res res = dd_parse_forwarded(value, &out);
141141
if (res.success) {
142142
return dd_ipaddr_to_zstr(&out);
143143
}
@@ -160,7 +160,7 @@ DDTRACE_PUBLIC zend_string *ddtrace_ip_extraction_find(zval *server) {
160160
zval *val = zend_hash_find(Z_ARR_P(server), priority_header_map[i].key);
161161
if (val && Z_TYPE_P(val) == IS_STRING && Z_STRLEN_P(val) > 0) {
162162
ipaddr out;
163-
__auto_type res = (priority_header_map[i].parse_fn)(Z_STR_P(val), &out);
163+
struct extract_res res = (priority_header_map[i].parse_fn)(Z_STR_P(val), &out);
164164
if (res.success) {
165165
if (!res.is_private) {
166166
return dd_ipaddr_to_zstr(&out);
@@ -176,7 +176,7 @@ DDTRACE_PUBLIC zend_string *ddtrace_ip_extraction_find(zval *server) {
176176
zend_string *value = dd_fetch_arr_str(server, _remote_addr_key);
177177
if (value) {
178178
ipaddr out;
179-
__auto_type res = dd_parse_plain(value, &out);
179+
struct extract_res res = dd_parse_plain(value, &out);
180180
if (res.success) {
181181
if (!res.is_private) {
182182
return dd_ipaddr_to_zstr(&out);
@@ -223,7 +223,6 @@ static zend_string *dd_ipaddr_to_zstr(const ipaddr *ipaddr) {
223223
char buf[INET6_ADDRSTRLEN];
224224
const char *res = inet_ntop(ipaddr->af, (char *)&ipaddr->v4, buf, sizeof(buf));
225225
if (!res) {
226-
LOG(Warn, "inet_ntop failed");
227226
return NULL;
228227
}
229228
return zend_string_init(res, strlen(res), 0);
@@ -459,11 +458,11 @@ static bool dd_is_private_v6(const struct in6_addr *addr) {
459458
static const struct {
460459
union {
461460
struct in6_addr base;
462-
unsigned __int128 base_i;
461+
uint64_t base_i[2];
463462
};
464463
union {
465464
struct in6_addr mask;
466-
unsigned __int128 mask_i;
465+
uint64_t mask_i[2];
467466
};
468467
} priv_ranges[] = {
469468
{
@@ -489,12 +488,12 @@ static bool dd_is_private_v6(const struct in6_addr *addr) {
489488
};
490489
// clang-format on
491490

492-
unsigned __int128 addr_i;
493-
memcpy(&addr_i, addr->s6_addr, sizeof(addr_i));
491+
uint64_t addr_i[2];
492+
memcpy(&addr_i[0], addr->s6_addr, sizeof(addr_i));
494493

495494
for (unsigned i = 0; i < ARRAY_SIZE(priv_ranges); i++) {
496-
__auto_type range = &priv_ranges[i];
497-
if ((addr_i & range->mask_i) == range->base_i) {
495+
if ((addr_i[0] & priv_ranges[i].mask_i[0]) == priv_ranges[i].base_i[0] &&
496+
(addr_i[1] & priv_ranges[i].mask_i[1]) == priv_ranges[i].base_i[1]) {
498497
return true;
499498
}
500499
}

ext/request_hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ZEND_EXTERN_MODULE_GLOBALS(ddtrace);
2727
#endif
2828

2929
int dd_execute_php_file(const char *filename) {
30-
int filename_len = strlen(filename);
30+
size_t filename_len = strlen(filename);
3131
if (filename_len == 0) {
3232
return FAILURE;
3333
}

ext/user_request.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,17 @@ PHP_FUNCTION(DDTrace_UserRequest_notify_commit)
123123
}
124124
}
125125

126+
if (status < 100 || status > 599) {
127+
zend_type_error("Status code must be between 100 and 599");
128+
return;
129+
}
130+
126131
bool free_headers = false;
127132

128133
zend_array *replacement_resp = NULL;
129134
for (size_t i = 0; i < reg_listeners.size; i++) {
130135
ddtrace_user_req_listeners *listener = reg_listeners.listeners[i];
131-
zend_array *repl = listener->response_committed(listener, span, status, headers, rbe_zv);
136+
zend_array *repl = listener->response_committed(listener, span, (int)status, headers, rbe_zv);
132137
if (repl) {
133138
{
134139
zval *new_status_zv = zend_hash_str_find(repl, ZEND_STRL("status"));

0 commit comments

Comments
 (0)