joes 2004/07/18 12:45:21
Modified: src apreq.c
t params.c
Log:
apreq_header_attribute returns APR_EGENERAL if the header is missing a
trailing quote. And don't advance hdr past v because *v could be 0 here. Also
rename memmem test 'test_memmem' to avoid symbol conflict with <string.h>'s
memmem.
Revision Changes Path
1.45 +4 -2 httpd-apreq-2/src/apreq.c
Index: apreq.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/src/apreq.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- apreq.c 17 Jul 2004 17:05:27 -0000 1.44
+++ apreq.c 18 Jul 2004 19:45:21 -0000 1.45
@@ -807,6 +807,8 @@
break;
}
}
+ /* bad attr: no terminating quote found */
+ return APR_EGENERAL;
}
else {
/* value is not wrapped in quotes */
@@ -827,13 +829,13 @@
finish:
if (strncasecmp(key, name, nlen) == 0
- && (key == hdr || !apr_isalpha(key[-1])))
+ && (key == hdr || !apr_isalnum(key[-1])))
{
*vlen = v - *val;
return APR_SUCCESS;
}
else
- hdr = v + 1;
+ hdr = v;
}
return APR_NOTFOUND;
1.19 +14 -3 httpd-apreq-2/t/params.c
Index: params.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/t/params.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- params.c 18 Jul 2004 05:27:27 -0000 1.18
+++ params.c 18 Jul 2004 19:45:21 -0000 1.19
@@ -91,7 +91,7 @@
static void header_attributes(CuTest *tc)
{
- const char hdr[] = "text/plain; boundary=\"-foo-\", charset=ISO-8859-1";
+ const char *hdr = "text/plain; boundary=\"-foo-\", charset=ISO-8859-1";
const char *val;
apr_size_t vlen;
apr_status_t s;
@@ -112,6 +112,17 @@
CuAssertIntEquals(tc, 10, vlen);
CuAssertStrNEquals(tc, "ISO-8859-1", val, 10);
+ hdr = "max-age=20; no-quote=\"...";
+
+ s = apreq_header_attribute(hdr, "max-age", 7, &val, &vlen);
+ CuAssertIntEquals(tc, APR_SUCCESS, s);
+ CuAssertIntEquals(tc, 2, vlen);
+ CuAssertStrNEquals(tc, "20", val, 2);
+
+ s = apreq_header_attribute(hdr, "no-quote", 8, &val, &vlen);
+ CuAssertIntEquals(tc, APR_EGENERAL, s);
+
+
}
static void make_values(CuTest *tc)
@@ -186,7 +197,7 @@
}
}
-static void memmem(CuTest *tc)
+static void test_memmem(CuTest *tc)
{
char *hay = apr_palloc(p,29);
char *partial, *full;
@@ -221,7 +232,7 @@
SUITE_ADD_TEST(suite, make_values);
SUITE_ADD_TEST(suite, quote_strings);
SUITE_ADD_TEST(suite, make_param);
- SUITE_ADD_TEST(suite, memmem);
+ SUITE_ADD_TEST(suite, test_memmem);
return suite;
}