You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jc...@apache.org on 2016/12/14 19:37:03 UTC
svn commit: r1774328 - in /httpd/test/framework/trunk:
c-modules/test_utilities/ c-modules/test_utilities/mod_test_utilities.c
t/conf/extra.conf.in t/modules/rewrite.t
Author: jchampion
Date: Wed Dec 14 19:37:03 2016
New Revision: 1774328
URL: http://svn.apache.org/viewvc?rev=1774328&view=rev
Log:
PR60478: add test case
Includes a utility ap_expr function to determine the length of a string
argument.
Added:
httpd/test/framework/trunk/c-modules/test_utilities/
httpd/test/framework/trunk/c-modules/test_utilities/mod_test_utilities.c (with props)
Modified:
httpd/test/framework/trunk/t/conf/extra.conf.in
httpd/test/framework/trunk/t/modules/rewrite.t
Added: httpd/test/framework/trunk/c-modules/test_utilities/mod_test_utilities.c
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/c-modules/test_utilities/mod_test_utilities.c?rev=1774328&view=auto
==============================================================================
--- httpd/test/framework/trunk/c-modules/test_utilities/mod_test_utilities.c (added)
+++ httpd/test/framework/trunk/c-modules/test_utilities/mod_test_utilities.c Wed Dec 14 19:37:03 2016
@@ -0,0 +1,48 @@
+/**
+ * This module provides utility functions for other tests; it doesn't provide
+ * test cases of its own.
+ */
+
+#define HTTPD_TEST_REQUIRE_APACHE 2
+
+#define APACHE_HTTPD_TEST_EXTRA_HOOKS util_register_hooks
+#include "apache_httpd_test.h"
+
+#include "apr_strings.h"
+#include "ap_expr.h"
+
+/**
+ * The util_strlen() ap_expr function simply returns the length of its string
+ * argument as a decimal string.
+ */
+static const char *util_strlen_func(ap_expr_eval_ctx_t *ctx, const void *data,
+ const char *arg)
+{
+ if (!arg) {
+ return NULL;
+ }
+
+ return apr_psprintf(ctx->p, "%" APR_SIZE_T_FMT, strlen(arg));
+}
+
+static int util_expr_lookup(ap_expr_lookup_parms *parms)
+{
+ switch (parms->type) {
+ case AP_EXPR_FUNC_STRING:
+ if (!strcasecmp(parms->name, "util_strlen")) {
+ *parms->func = util_strlen_func;
+ *parms->data = "dummy";
+ return OK;
+ }
+ break;
+ }
+
+ return DECLINED;
+}
+
+static void util_register_hooks(apr_pool_t *p)
+{
+ ap_hook_expr_lookup(util_expr_lookup, NULL, NULL, APR_HOOK_MIDDLE);
+}
+
+APACHE_HTTPD_TEST_MODULE(test_utilities);
Propchange: httpd/test/framework/trunk/c-modules/test_utilities/mod_test_utilities.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: httpd/test/framework/trunk/t/conf/extra.conf.in
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/conf/extra.conf.in?rev=1774328&r1=1774327&r2=1774328&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/conf/extra.conf.in (original)
+++ httpd/test/framework/trunk/t/conf/extra.conf.in Wed Dec 14 19:37:03 2016
@@ -255,6 +255,16 @@
RewriteRule (.*) http://localhost$1 [P]
</VirtualHost>
+ # PR60478: pathological rewrite expansion
+ <Location /modules/rewrite/pr60478-rewrite-loop>
+ # This pair of RewriteRules will loop but should eventually 500 once we
+ # reach LimitRequestLine * 2 bytes. (In this case, 128 * 2 = 256.)
+ RewriteRule ^(.*)X(.*)$ $1x$2
+ # Don't run the test machine out of memory on failure, just stop the loop
+ RewriteCond expr "util_strlen(%{REQUEST_FILENAME}) -lt 257"
+ RewriteRule X - [N]
+ </Location>
+
</IfModule>
Modified: httpd/test/framework/trunk/t/modules/rewrite.t
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/modules/rewrite.t?rev=1774328&r1=1774327&r2=1774328&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/modules/rewrite.t (original)
+++ httpd/test/framework/trunk/t/modules/rewrite.t Wed Dec 14 19:37:03 2016
@@ -24,7 +24,7 @@ if (!have_min_apache_version('2.4')) {
push @todo, 24
}
-plan tests => @map * @num + 15, todo => \@todo, need_module 'rewrite';
+plan tests => @map * @num + 16, todo => \@todo, need_module 'rewrite';
foreach (@map) {
foreach my $n (@num) {
@@ -114,3 +114,7 @@ if (have_module('mod_proxy') && have_cgi
} else {
skip "Skipping rewrite QUERY_STRING test; missing proxy or CGI module" foreach (1..5);
}
+
+# See PR 60478 and the corresponding config in extra.conf
+$r = GET("/modules/rewrite/pr60478-rewrite-loop/a/X/b/c");
+ok t_cmp($r->code, 500, "PR 60478 rewrite loop is halted");
Re: svn commit: r1774328 - in /httpd/test/framework/trunk:
c-modules/test_utilities/ c-modules/test_utilities/mod_test_utilities.c
t/conf/extra.conf.in t/modules/rewrite.t
Posted by Jacob Champion <ch...@gmail.com>.
On 12/19/2016 12:57 PM, Ruediger Pluem wrote:
> This breaks the test suite for httpd 2.2.x.:
Should be fixed now. (Sorry it took so long; turns out
HTTPD_TEST_REQUIRE_APACHE doesn't work correctly if it's not the first
line...)
I chose to disable the test entirely for 2.2, since AFAIK there's no
intention to backport a fix there. If that's not true, we can still
enable the test without the utility module -- the downside is that a
failing test would then run the server out of memory.
Thanks again!
--Jacob
Re: svn commit: r1774328 - in /httpd/test/framework/trunk:
c-modules/test_utilities/ c-modules/test_utilities/mod_test_utilities.c
t/conf/extra.conf.in t/modules/rewrite.t
Posted by Jacob Champion <ch...@gmail.com>.
On 12/19/2016 12:57 PM, Ruediger Pluem wrote:
> This breaks the test suite for httpd 2.2.x.:
Oof, thanks for the catch. Didn't consider the effects on 2.2...
--Jacob
Re: svn commit: r1774328 - in /httpd/test/framework/trunk:
c-modules/test_utilities/ c-modules/test_utilities/mod_test_utilities.c
t/conf/extra.conf.in t/modules/rewrite.t
Posted by Ruediger Pluem <rp...@apache.org>.
On 12/14/2016 08:37 PM, jchampion@apache.org wrote:
> Author: jchampion
> Date: Wed Dec 14 19:37:03 2016
> New Revision: 1774328
>
> URL: http://svn.apache.org/viewvc?rev=1774328&view=rev
> Log:
> PR60478: add test case
>
> Includes a utility ap_expr function to determine the length of a string
> argument.
>
> Added:
> httpd/test/framework/trunk/c-modules/test_utilities/
> httpd/test/framework/trunk/c-modules/test_utilities/mod_test_utilities.c (with props)
> Modified:
> httpd/test/framework/trunk/t/conf/extra.conf.in
> httpd/test/framework/trunk/t/modules/rewrite.t
>
> Added: httpd/test/framework/trunk/c-modules/test_utilities/mod_test_utilities.c
> URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/c-modules/test_utilities/mod_test_utilities.c?rev=1774328&view=auto
> ==============================================================================
> --- httpd/test/framework/trunk/c-modules/test_utilities/mod_test_utilities.c (added)
> +++ httpd/test/framework/trunk/c-modules/test_utilities/mod_test_utilities.c Wed Dec 14 19:37:03 2016
> @@ -0,0 +1,48 @@
> +/**
> + * This module provides utility functions for other tests; it doesn't provide
> + * test cases of its own.
> + */
> +
> +#define HTTPD_TEST_REQUIRE_APACHE 2
> +
> +#define APACHE_HTTPD_TEST_EXTRA_HOOKS util_register_hooks
> +#include "apache_httpd_test.h"
> +
> +#include "apr_strings.h"
> +#include "ap_expr.h"
> +
> +/**
> + * The util_strlen() ap_expr function simply returns the length of its string
> + * argument as a decimal string.
> + */
> +static const char *util_strlen_func(ap_expr_eval_ctx_t *ctx, const void *data,
> + const char *arg)
> +{
> + if (!arg) {
> + return NULL;
> + }
> +
> + return apr_psprintf(ctx->p, "%" APR_SIZE_T_FMT, strlen(arg));
> +}
> +
> +static int util_expr_lookup(ap_expr_lookup_parms *parms)
> +{
> + switch (parms->type) {
> + case AP_EXPR_FUNC_STRING:
> + if (!strcasecmp(parms->name, "util_strlen")) {
> + *parms->func = util_strlen_func;
> + *parms->data = "dummy";
> + return OK;
> + }
> + break;
> + }
> +
> + return DECLINED;
> +}
> +
> +static void util_register_hooks(apr_pool_t *p)
> +{
> + ap_hook_expr_lookup(util_expr_lookup, NULL, NULL, APR_HOOK_MIDDLE);
> +}
This breaks the test suite for httpd 2.2.x.:
mod_test_utilities.c:12:21: error: ap_expr.h: No such file or directory
mod_test_utilities.c:18: error: expected \u2018)\u2019 before \u2018*\u2019 token
mod_test_utilities.c:28: error: expected \u2018)\u2019 before \u2018*\u2019 token
mod_test_utilities.c: In function \u2018util_register_hooks\u2019:
mod_test_utilities.c:45: warning: implicit declaration of function \u2018ap_hook_expr_lookup\u2019
mod_test_utilities.c:45: error: \u2018util_expr_lookup\u2019 undeclared (first use in this function)
mod_test_utilities.c:45: error: (Each undeclared identifier is reported only once
mod_test_utilities.c:45: error: for each function it appears in.)
apxs:Error: Command failed with rc=65536
Regards
R�diger