From ef18503f0528c9fba1ccbd6e7664377e7160f1b7 Mon Sep 17 00:00:00 2001 From: brectanus Date: Thu, 20 Dec 2007 21:33:29 +0000 Subject: [PATCH] More cleanup and fixes in the testing framework. --- apache2/msc_test.c | 4 ++-- apache2/t/run-tests.pl | 8 +++----- apache2/t/tfn/escapeSeqDecode.t | 26 ++++++++++++++++++++++++-- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/apache2/msc_test.c b/apache2/msc_test.c index b0095ec2..fa839f11 100644 --- a/apache2/msc_test.c +++ b/apache2/msc_test.c @@ -323,7 +323,7 @@ int main(int argc, const char * const argv[]) type = argv[1]; name = argv[2]; param_len = strlen(argv[3]); - param = (unsigned char *)apr_pstrmemdup(g_mp, argv[3], param_len); + param = apr_pmemdup(g_mp, argv[3], param_len + 1); unescape_inplace(param, ¶m_len); if (argc >= 5) { returnval = argv[4]; @@ -365,7 +365,7 @@ int main(int argc, const char * const argv[]) result = RESULT_WRONGRET; } else if (param_len != out_len) { - fprintf(stderr, "Lenth %" APR_SIZE_T_FMT " (param %" APR_SIZE_T_FMT ")\n", out_len, param_len); + fprintf(stderr, "Lenth %" APR_SIZE_T_FMT " (expected %" APR_SIZE_T_FMT ")\n", out_len, param_len); result = RESULT_WRONGSIZE; } else { diff --git a/apache2/t/run-tests.pl b/apache2/t/run-tests.pl index 5eb185e3..cb0a6cd5 100755 --- a/apache2/t/run-tests.pl +++ b/apache2/t/run-tests.pl @@ -68,16 +68,14 @@ sub runfile { my %t = %{$t || {}}; my $id = sprintf("%6d", $n); my $in = $t{input}; - my $out = escape($t{output}); # Escape so we can send via commandline - quit(1, "Failed to interpret output \"$cfg\": $@") if ($@); - my $param; my $rc = 0; + my $param; if ($t{type} eq "tfn") { - $param = $t{output}; + $param = escape($t{output}); } elsif ($t{type} eq "op") { - $param = $t{param}; + $param = escape($t{param}); } else { quit(1, "Unknown type \"$t{type}\" - should be one of: " . join(",",@TYPES)); diff --git a/apache2/t/tfn/escapeSeqDecode.t b/apache2/t/tfn/escapeSeqDecode.t index cbba89c2..7f362e9b 100644 --- a/apache2/t/tfn/escapeSeqDecode.t +++ b/apache2/t/tfn/escapeSeqDecode.t @@ -41,14 +41,14 @@ ### Invalid Sequences # \8 and \9 are not octal -# \666 is a byte overflow (0x1b6) and should be truncated to a byte as \xff +# \666 is a byte overflow (0x1b6) and should be truncated to a byte as 0xb6 # \xag and \xga are not hex, # \0123 is \012 + '3' { type => "tfn", name => "escapeSeqDecode", input => "\\8\\9\\666\\xag\\xga\\0123", - output => "89\xffxagxga\x0a3", + output => "89\xb6xagxga\x0a3", ret => 1, }, @@ -74,6 +74,28 @@ output => "xx0\0", ret => 1, }, +# Octal at end +{ + type => "tfn", + name => "escapeSeqDecode", + input => "\\0", + output => "\x00", + ret => 1, +}, +{ + type => "tfn", + name => "escapeSeqDecode", + input => "\\01", + output => "\x01", + ret => 1, +}, +{ + type => "tfn", + name => "escapeSeqDecode", + input => "\\012", + output => "\x0a", + ret => 1, +}, # A forward slash with nothing after { type => "tfn",