Welcome! Log In Create A New Profile

Advanced

[PATCH] Perl: NULL-terminate argument list

Piotr Sikora
June 19, 2014 07:20AM
# HG changeset patch
# User Piotr Sikora <piotr@cloudflare.com>
# Date 1403176596 25200
# Thu Jun 19 04:16:36 2014 -0700
# Node ID 290f3fcb9cf552c235b9807cf0af3830b5add5af
# Parent 675bda8dcfdbf66e4a17017839f39ed6c8cbb9f5
Perl: NULL-terminate argument list.

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 <piotr@cloudflare.com>

diff -r 675bda8dcfdb -r 290f3fcb9cf5 src/http/modules/perl/ngx_http_perl_module.c
--- a/src/http/modules/perl/ngx_http_perl_module.c Thu Jun 19 13:55:59 2014 +0400
+++ b/src/http/modules/perl/ngx_http_perl_module.c Thu Jun 19 04:16:36 2014 -0700
@@ -577,7 +577,7 @@ ngx_http_perl_create_interpreter(ngx_con

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;
}
@@ -595,6 +595,7 @@ ngx_http_perl_create_interpreter(ngx_con
embedding[n++] = "-Mnginx";
embedding[n++] = "-e";
embedding[n++] = "0";
+ embedding[n] = NULL;

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


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Perl: NULL-terminate argument list

Piotr Sikora 744 June 19, 2014 07:20AM

Re: [PATCH] Perl: NULL-terminate argument list

Maxim Dounin 343 June 19, 2014 09:28AM

Re: [PATCH] Perl: NULL-terminate argument list

Piotr Sikora 325 June 20, 2014 05:48AM

Re: [PATCH] Perl: NULL-terminate argument list

Maxim Dounin 304 June 20, 2014 03:42PM

Re: [PATCH] Perl: NULL-terminate argument list

Piotr Sikora 382 June 20, 2014 07:10PM

Re: [PATCH] Perl: NULL-terminate argument list

Piotr Sikora 307 August 05, 2014 04:40AM

Re: [PATCH] Perl: NULL-terminate argument list

Maxim Dounin 411 August 05, 2014 05:12AM

Re: [PATCH] Perl: NULL-terminate argument list

Piotr Sikora 509 August 05, 2014 06:34AM

Re: [PATCH] Perl: NULL-terminate argument list

Maxim Dounin 339 August 05, 2014 05:28PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 170
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready