Skip to content

Commit 497bc6b

Browse files
authored
fix: off one memory write access (#20)
1 parent 5812f2b commit 497bc6b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/http/ngx_http_wasm_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ proxy_get_property(int32_t path_data, int32_t path_size,
9393
return PROXY_RESULT_INVALID_MEMORY_ACCESS;
9494
}
9595

96-
if (ngx_strncmp(p, "plugin_root_id", sizeof("plugin_root_id") - 1) == 0) {
96+
if (path_size == 14 && ngx_strncmp(p, "plugin_root_id", 14) == 0) {
97+
/* assemblyscript SDK assumes plugin_root_id is always given */
9798
ngx_str_t *name;
9899

99100
name = ngx_http_wasm_get_plugin_name();

src/http/ngx_http_wasm_module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ ngx_http_wasm_load_plugin(const char *name, size_t name_len,
199199
hw_plugin->name.data = (u_char *) (hw_plugin + 1);
200200
ngx_memcpy(hw_plugin->name.data, name, name_len);
201201

202-
hw_plugin->state = (ngx_http_wasm_state_t *) (hw_plugin->name.data + name_len + 1);
202+
hw_plugin->state = (ngx_http_wasm_state_t *) (hw_plugin->name.data + name_len);
203203
hw_plugin->state->plugin_name = &hw_plugin->name;
204204

205205
ngx_queue_init(&hw_plugin->occupied);

0 commit comments

Comments
 (0)