Skip to content

Commit

Permalink
bugfix: sprintf override malloc metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
kingluo committed Feb 26, 2023
1 parent dc03981 commit 2c5f6d4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ngx_http_lua_ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ lua_resty_ffi_init()

const uint8_t *build_id = build_id_data(note);

char* buf = (char*)calloc(len*2, 1);
char* buf = (char*)calloc(len*2+100, 1);
for (ElfW(Word) i = 0; i < len; i++) {
sprintf(buf + strlen(buf), "%02x", build_id[i]);
}
Expand All @@ -101,6 +101,7 @@ lua_resty_ffi_init()
addr = (char*)&ngx_calloc;
addr += NGX_THREAD_POOL_HANDLER_OFFSET;
ngx_thread_pool_handler = (ngx_event_handler_pt)addr;
printf("%p %p %p\n", &ngx_cycle, ngx_thread_pool_done, ngx_thread_pool_done_lock);

free(buf);

Expand Down

0 comments on commit 2c5f6d4

Please sign in to comment.