Skip to content

Commit ba1f0e6

Browse files
Jake ChampionJakeChampion
authored andcommitted
fix: allow a downstream response to contain lots of headers with the same name without crashing
1 parent b2a661f commit ba1f0e6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

c-dependencies/js-compute-runtime/xqd-world/xqd_world_adapter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ bool xqd_fastly_http_resp_header_names_get(fastly_response_handle_t h, fastly_li
452452
bool xqd_fastly_http_resp_header_values_get(fastly_response_handle_t h, xqd_world_string_t *name,
453453
fastly_option_list_string_t *ret, fastly_error_t *err) {
454454
size_t str_max = LIST_ALLOC_SIZE;
455-
xqd_world_string_t *strs = static_cast<xqd_world_string_t *>(cabi_malloc(str_max, 1));
455+
xqd_world_string_t *strs =
456+
static_cast<xqd_world_string_t *>(cabi_malloc(str_max * sizeof(xqd_world_string_t), 1));
456457
size_t str_cnt = 0;
457458
size_t nwritten;
458459
char *buf = static_cast<char *>(cabi_malloc(HOSTCALL_BUFFER_LEN, 1));
@@ -485,7 +486,7 @@ bool xqd_fastly_http_resp_header_values_get(fastly_response_handle_t h, xqd_worl
485486
}
486487
if (next_cursor < 0)
487488
break;
488-
cursor = (uint32_t)next_cursor;
489+
cursor = static_cast<uint32_t>(next_cursor);
489490
}
490491
cabi_free(buf);
491492
if (str_cnt > 0) {

integration-tests/js-compute/fixtures/multiple-set-cookie/tests.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"pathname": "/multiple-set-cookie/downstream"
5757
},
5858
"downstream_response": {
59-
"status": 200,
59+
"status": 302,
6060
"headers": [
6161
["Set-Cookie", "test=1; expires=Tue, 06-Dec-2022 12:34:56 GMT; Max-Age=60; Path=/; HttpOnly; Secure"],
6262
["Set-Cookie", "test_id=1; Max-Age=60; Path=/; expires=Tue, 06-Dec-2022 12:34:56 GMT"],

0 commit comments

Comments
 (0)