httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Clark <g...@dcs.ed.ac.uk>
Subject Re: small bug in string unescaping
Date Fri, 18 Jul 2003 15:36:24 GMT

> This is exactly the sort of bug our test framework needs to
> expose.  If you need any help writing the test, please don't 
> hesitate to ask.

Well that was an interesting lesson - don't try to modify data in the
.rodata section :-)

I modified the first patch to prevent a compiler warning too. How
about these?

Graham

Index: src/apreq.c
===================================================================
RCS file: /home/cvspublic/httpd-apreq-2/src/apreq.c,v
retrieving revision 1.24
diff -u -r1.24 apreq.c
--- src/apreq.c	30 Jun 2003 20:42:14 -0000	1.24
+++ src/apreq.c	18 Jul 2003 15:29:02 -0000
@@ -333,6 +333,7 @@
             else if (*s == 0)
                 return s - (const char *)d;
         }
+	d = (char *)s;
     }
 
     for (; s < end; ++d, ++s) {


Index: t/params.c
===================================================================
RCS file: /home/cvspublic/httpd-apreq-2/t/params.c,v
retrieving revision 1.5
diff -u -r1.5 params.c
--- t/params.c	8 Jun 2003 18:37:56 -0000	1.5
+++ t/params.c	18 Jul 2003 15:35:44 -0000
@@ -92,6 +92,26 @@
 
 }
 
+static void string_decoding_in_place(CuTest *tc)
+{
+    apreq_value_t *v;
+    char *s1 = malloc(4096);
+    char *s2 = malloc(4096);
+
+    strcpy(s1, "bend it like beckham");
+    strcpy(s2, "dandy %3Edons");
+
+    CuAssertStrEquals(tc,"bend it like beckham",s1);
+    apreq_unescape(s1);
+    CuAssertStrEquals(tc,"bend it like beckham",s1);
+    CuAssertStrEquals(tc,"dandy %3Edons",s2);
+    apreq_unescape(s2);
+    CuAssertStrEquals(tc,"dandy >dons",s2);
+    
+    free(s2);
+    free(s1);
+}
+
 
 CuSuite *testparam(void)
 {
@@ -99,6 +119,7 @@
 
     SUITE_ADD_TEST(suite, request_make);
     SUITE_ADD_TEST(suite, request_args_get);
+    SUITE_ADD_TEST(suite, string_decoding_in_place);
     return suite;
 }
 

Mime
View raw message