Skip to content

Commit

Permalink
Perl: NULL-terminate argument list.
Browse files Browse the repository at this point in the history
perl_parse() function expects argv/argc-style argument list,
which according to the C standard must be NULL-terminated,
that is: argv[argc] == NULL.

This change fixes a crash (SIGSEGV) that could happen because
of the buffer overrun during perl module initialization.

Signed-off-by: Piotr Sikora <[email protected]>
  • Loading branch information
PiotrSikora committed Jun 19, 2014
1 parent 8f0f4c1 commit b3066b1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/http/modules/perl/ngx_http_perl_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ ngx_http_perl_create_interpreter(ngx_conf_t *cf,

n = (pmcf->modules != NGX_CONF_UNSET_PTR) ? pmcf->modules->nelts * 2 : 0;

embedding = ngx_palloc(cf->pool, (4 + n) * sizeof(char *));
embedding = ngx_palloc(cf->pool, (5 + n) * sizeof(char *));
if (embedding == NULL) {
goto fail;
}
Expand All @@ -595,6 +595,7 @@ ngx_http_perl_create_interpreter(ngx_conf_t *cf,
embedding[n++] = "-Mnginx";
embedding[n++] = "-e";
embedding[n++] = "0";
embedding[n] = NULL;

n = perl_parse(perl, ngx_http_perl_xs_init, n, embedding, NULL);

Expand Down

0 comments on commit b3066b1

Please sign in to comment.