summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules/perl/ngx_http_perl_module.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-07-12Perl: named locations in $r->internal_redirect().Maxim Dounin1-6/+12
2019-07-12Perl: expect escaped URIs in $r->internal_redirect().Maxim Dounin1-1/+9
Similarly to the change in 5491:74bfa803a5aa (1.5.9), we should accept properly escaped URIs and unescape them as needed, else it is not possible to handle URIs with question marks.
2019-07-12Perl: additional ctx->header_sent checks.Maxim Dounin1-0/+1
As we now have ctx->header_sent flag, it is further used to prevent duplicate $r->send_http_header() calls, prevent output before sending header, and $r->internal_redirect() after sending header. Further, $r->send_http_header() protected from calls after $r->internal_redirect().
2019-07-12Perl: avoid returning 500 if header was already sent.Maxim Dounin1-0/+4
Returning NGX_HTTP_INTERNAL_SERVER_ERROR if a perl code died after sending header will lead to a "header already sent" alert. To avoid it, we now check if header was already sent, and return NGX_ERROR instead if it was.
2019-07-12Perl: avoid redirects on errors.Maxim Dounin1-0/+2
Previously, redirects scheduled with $r->internal_redirect() were followed even if the code then died. Now these are ignored and nginx will return an error instead.
2019-07-12Perl: disabled unrelated calls from variable handlers.Maxim Dounin1-0/+5
Variable handlers are not expected to send anything to the client, cannot sleep or read body, and are not expected to modify the request. Added appropriate protection to prevent accidental foot shooting.
2019-07-12Perl: propagate errors.Maxim Dounin1-0/+20
When an error happens, the ctx->error bit is now set, and croak() is called to terminate further processing. The ctx->error bit is checked in ngx_http_perl_call_handler() to cancel further processing, and is also checked in various output functions - to make sure these won't be called if croak() was handled by an eval{} in perl code. In particular, this ensures that output chain won't be called after errors, as filters might not expect this to happen. This fixes some segmentation faults under low memory conditions. Also this stops request processing after filter finalization or request body reading errors. For cases where an HTTP error status can be additionally returned (for example, 416 (Requested Range Not Satisfiable) from the range filter), the ctx->status field is also added.
2019-07-12Perl: reworked perl module to pass ctx instead of request.Maxim Dounin1-9/+17
This ensures that correct ctx is always available, including after filter finalization. In particular, this fixes a segmentation fault with the following configuration: location / { image_filter test; perl 'sub { my $r = shift; $r->send_http_header(); $r->print("foo\n"); $r->print("bar\n"); }'; } This also seems to be the only way to correctly handle filter finalization in various complex cases, for example, when embedded perl is used both in the original handler and in an error page called after filter finalization.
2019-07-11Perl: removed unneeded NGX_DONE test.Maxim Dounin1-5/+0
The NGX_DONE test in ngx_http_perl_handle_request() was introduced in 1702:86bb52e28ce0, which also modified ngx_http_perl_call_handler() to return NGX_DONE with c->destroyed. The latter part was then removed in 3050:f54b02dbb12b, so NGX_DONE test is no longer needed.
2017-04-02Moved handling of wev->delayed to the connection event handler.Maxim Dounin1-4/+1
With post_action or subrequests, it is possible that the timer set for wev->delayed will expire while the active subrequest write event handler is not ready to handle this. This results in request hangs as observed with limit_rate / sendfile_max_chunk and post_action (ticket #776) or subrequests (ticket #1228). Moving the handling to the connection event handler fixes the hangs observed, and also slightly simplifies the code.
2017-04-02Perl: fixed delaying subrequests.Maxim Dounin1-6/+10
Much like in limit_req, use the wev->delayed flag to ensure proper handling and interoperability with limit_rate.
2016-12-07Perl: added PERL_SET_INTERP().Maxim Dounin1-0/+8
For Perl compiled with threads, without PERL_SET_INTERP() the PL_curinterp remains set to the first interpreter created (that is, one created at original start). As a result after a reload Perl thinks that operations are done withing a thread, and, most notably, denies to change environment. For example, the following code properly works on original start, but fails after a reload: perl 'sub { my $r = shift; $r->send_http_header("text/plain"); $ENV{TZ} = "UTC"; $r->print("tz: " . $ENV{TZ} . " (localtime " . (localtime()) . ")\n"); $ENV{TZ} = "Europe/Moscow"; $r->print("tz: " . $ENV{TZ} . " (localtime " . (localtime()) . ")\n"); return OK; }'; To fix this, PERL_SET_INTERP() added anywhere where PERL_SET_CONTEXT() was previously used. Note that PERL_SET_INTERP() doesn't seem to be documented anywhere. Yet it is used in some other software, and also seems to be the only solution possible.
2016-11-01Perl: fixed optimization in SSI command handler.Maxim Dounin1-1/+1
As the pointer to the first argument was tested instead of the argument itself, array of arguments was always created, even if there were no arguments. Fix is to test args[0] instead of args. Found by Coverity (CID 1356862).
2014-06-19Perl: NULL-terminate argument list.Piotr Sikora1-1/+2
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>
2013-09-04Handling of ngx_int_t != intptr_t case.Maxim Dounin1-2/+2
Casts between pointers and integers produce warnings on size mismatch. To silence them, cast to (u)intptr_t should be used. Prevoiusly, casts to ngx_(u)int_t were used in some cases, and several ngx_int_t expressions had no casts. As of now it's mostly style as ngx_int_t is defined as intptr_t.
2013-08-20Backed out f1a91825730a and 7094bd12c1ff.Maxim Dounin1-3/+1
While ngx_get_full_name() might have a bit more descriptive arguments, the ngx_conf_full_name() is generally easier to use when parsing configuration and limits exposure of cycle->prefix / cycle->conf_prefix details.
2013-08-06Replaced ngx_conf_full_name() with ngx_get_full_name().Valentin Bartenev1-1/+3
The ngx_get_full_name() function takes more readable arguments list.
2012-12-17Added checks that disallow adding a variable with an empty name.Ruslan Ermilov1-1/+1
Added variable name syntax checks to "geo" and "map" directives.
2012-12-13Fixed variable syntax checking in "set", "geo", "limit_conn_zone",Ruslan Ermilov1-1/+1
and "perl_set" directives.
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2010-05-24remove r->zero_in_uriIgor Sysoev1-4/+0
2010-05-14ngx_str_set() and ngx_str_null()Igor Sysoev1-2/+1
2010-02-12delete ngx_http_perl_cleanup_t unused since r909Igor Sysoev1-6/+0
2009-11-17add comment from r2716 commit messageIgor Sysoev1-0/+6
2009-11-17use global perl variable in perl_destruct()/perl_free()Igor Sysoev1-16/+11
for non-mulitiplicity perl
2009-09-30allow several perl_modulesIgor Sysoev1-16/+42
2009-09-28use ngx_conf_set_str_array_slot() for perl_requireIgor Sysoev1-37/+13
2009-09-28optimize error handlingIgor Sysoev1-14/+9
2009-09-15allow perl "sub{..."Igor Sysoev1-1/+4
2009-09-08fix request counter handling in perl module for $r->internal_redirect()Igor Sysoev1-0/+3
and $r->has_request_body(), the bug was introduced in r3050
2009-09-04fix request counter handling for perl handler, introduced in r3050Igor Sysoev1-3/+5
2009-08-26axe r->connection->destroyed testingIgor Sysoev1-9/+0
2009-06-02return NULL instead of NGX_CONF_ERROR on a create conf failureIgor Sysoev1-2/+2
2009-04-18remove TODO commentsIgor Sysoev1-1/+0
2009-04-16perl termination fixes:Igor Sysoev1-5/+25
*) master exit hook is run before global pool cleanup, so call PERL_SYS_TERM() after perl_destruct()/perl_free(). This fixes the message panic: MUTEX_LOCK (22) [op.c:352] on some threaded perl builds *) call perl_destruct()/perl_free() before PERL_SYS_TERM() for non-mulitiplicity perl
2009-04-15fix segfault on exit if no http section is defined in confguraiton,Igor Sysoev1-6/+4
the bug has been introduced in r1947
2009-04-15fix segfault if no http section is defined in confguraiton,Igor Sysoev1-7/+5
the bug has been introduced in r1259
2008-12-09use "!= NGX_OK" instead of "== NGX_ERROR"Igor Sysoev1-1/+1
2008-06-17*) back out r2040Igor Sysoev1-1/+1
*) refactor ngx_palloc() *) introduce ngx_pnalloc() *) additional pool blocks have smaller header
2008-03-17some perl builds require my_perl for PERL_SYS_TERM()Igor Sysoev1-0/+11
2008-03-14style fixIgor Sysoev1-0/+1
2008-03-13fix building on 64-bit platforms broken in r1900Igor Sysoev1-1/+1
2008-02-16pass additional arguments in ngx_http_perl_call_handler() as SVIgor Sysoev1-12/+33
2008-02-16optimize $r->sleepIgor Sysoev1-8/+1
2007-12-09fix segfault when $r->has_request_body() is called with ready bodyIgor Sysoev1-11/+26
2007-10-14fix English grammarIgor Sysoev1-2/+2
2007-07-29--sysconfdir=DIRIgor Sysoev1-1/+1
2007-06-16fix building on threaded or multiplicity interpreter perl,Igor Sysoev1-0/+11
the bug was introduced by previous commit
2007-06-15set worker's perl $$Igor Sysoev1-1/+12
2007-05-29PERL_SYS_TERM() should be called once on exit only, this fixes the messageIgor Sysoev1-5/+13
panic: MUTEX_LOCK (22) [op.c:352]. BEGIN failed--compilation aborted. ... [alert] ... perl_parse() failed: 9 Scalars leaked: 2 on threaded perl during second reconfiguration. PERL_SYS_INIT() should be called once too.