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

potential incorrect check in ngx_http_subs_init_context #51

Open
leeriorio opened this issue Sep 11, 2024 · 0 comments
Open

potential incorrect check in ngx_http_subs_init_context #51

leeriorio opened this issue Sep 11, 2024 · 0 comments

Comments

@leeriorio
Copy link

In result of static analyse of nginx sources (including this module) code with Svace static analyzer I found error of cathegory "NULL_AFTER_DEREF" (situations where first, a pointer is dereferenced, and then it is compared to null) in ngx_http_subs_filter_module.c

the problem affects ngx_http_subs_init_context() function on lines 295-299

https://github.com/yaoweibin/ngx_http_substitutions_filter_module/blob/master/ngx_http_subs_filter_module.c#L295-L299

294
295    ctx->sub_pairs = ngx_array_create(r->pool, slcf->sub_pairs->nelts,
296                                      sizeof(sub_pair_t));
297    if (slcf->sub_pairs == NULL) {
298        return NGX_ERROR;
299    }
300

Is it correct to compare slcf->sub_pairs with NULL in line 297 after dereference of it in line 295? Should it be ctx->sub_pairs instead of slcf->sub_pairs in comparison?

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

No branches or pull requests

1 participant