Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maage: fix: use memchr to scan ngx_string #11

Merged
merged 1 commit into from Aug 12, 2023

Conversation

maage
Copy link

@maage maage commented Jan 30, 2017

Field is not \0 terminated.

==13043==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x621000074100 at pc 0x563ba79d56c9 bp 0x7ffec6e4cf70 sp 0x7ffec6e4c720
READ of size 4097 at 0x621000074100 thread T0

==13043==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x621000074100 at pc 0x563ba79d56c9 bp 0x7ffec6e4cf70 sp 0x7ffec6e4c720
READ of size 4097 at 0x621000074100 thread T0
@@ -514,7 +514,8 @@ ngx_http_eval_parse_param(ngx_http_request_t *r, ngx_http_eval_ctx_t *ctx,
ngx_str_t name;
ngx_str_t value;

p = (u_char *) ngx_strchr(param->data, '=');
/* param->data is not \0 terminated */
p = (u_char *) memchr(param->data, '=', param->len);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
p = (u_char *) memchr(param->data, '=', param->len);
p = (u_char *) ngx_strlchr(param->data, param->data + param->len, '=');

@zhuizhuhaomeng zhuizhuhaomeng merged commit f68f073 into openresty:master Aug 12, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants