summaryrefslogtreecommitdiff
path: root/test/testbuckets.c
diff options
context:
space:
mode:
authorStefan Fritsch <sf@apache.org>2012-10-27 21:56:58 +0000
committerStefan Fritsch <sf@apache.org>2012-10-27 21:56:58 +0000
commit93d370f9d28010a3374f481d9cd198ec4833f7e2 (patch)
tree152e25293268eba58fc3367a3ac26890fda293c7 /test/testbuckets.c
parent84671572b4954da80e51b3da3a35ffed11e26516 (diff)
downloadapr-93d370f9d28010a3374f481d9cd198ec4833f7e2.tar.gz
Fix potential data corruption in apr_brigade_write() and friends if
the last bucket of the brigade is a heap bucket that has been split, and there are still references to the next part of the original bucket in use. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1402897 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testbuckets.c')
-rw-r--r--test/testbuckets.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/testbuckets.c b/test/testbuckets.c
index 954b474c5..ec65fa760 100644
--- a/test/testbuckets.c
+++ b/test/testbuckets.c
@@ -469,6 +469,25 @@ static void test_partition(abts_case *tc, void *data)
apr_bucket_alloc_destroy(ba);
}
+static void test_write_split(abts_case *tc, void *data)
+{
+ apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p);
+ apr_bucket_brigade *bb1 = apr_brigade_create(p, ba);
+ apr_bucket_brigade *bb2;
+ apr_bucket *e;
+
+ e = apr_bucket_heap_create(hello, strlen(hello), NULL, ba);
+ APR_BRIGADE_INSERT_HEAD(bb1, e);
+ apr_bucket_split(e, strlen("hello, "));
+ bb2 = apr_brigade_split(bb1, APR_BRIGADE_LAST(bb1));
+ apr_brigade_write(bb1, NULL, NULL, "foo", strlen("foo"));
+ test_bucket_content(tc, APR_BRIGADE_FIRST(bb2), "world", 5);
+
+ apr_brigade_destroy(bb1);
+ apr_brigade_destroy(bb2);
+ apr_bucket_alloc_destroy(ba);
+}
+
abts_suite *testbuckets(abts_suite *suite)
{
suite = ADD_SUITE(suite);
@@ -484,6 +503,7 @@ abts_suite *testbuckets(abts_suite *suite)
abts_run_test(suite, test_manyfile, NULL);
abts_run_test(suite, test_truncfile, NULL);
abts_run_test(suite, test_partition, NULL);
+ abts_run_test(suite, test_write_split, NULL);
return suite;
}