ASF Bugzilla – Attachment 37130 Details for
Bug 64273
apr-util: apr_brigade_split_line leaves empty bucket when line ends with linefeed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Simple test program to demonstrate the issue
apr_splittest.c (text/x-csrc), 1.98 KB, created by
Barnim Dzwillo
on 2020-03-27 11:54:02 UTC
(
hide
)
Description:
Simple test program to demonstrate the issue
Filename:
MIME Type:
Creator:
Barnim Dzwillo
Created:
2020-03-27 11:54:02 UTC
Size:
1.98 KB
patch
obsolete
>/* apr_splittest: check for empty bucket after split_line > * > * build: gcc -Wall -g -Iapr-util-1.6.1/include -Iapr-1.7.0/include -Lapr-util-1.6.1/.libs -Lapr-1.7.0/.libs -o apr_splittest apr_splittest.c -laprutil-1 -lapr-1 -lpthread > * or: gcc -Wall -g -Iapr-trunk/include -Lapr-trunk/.libs -o apr_splittest apr_splittest.c -lapr-2 -lpthread > */ >#include <stdio.h> >#include <stdlib.h> >#include <assert.h> >#include "apr_pools.h" >#include "apr_buckets.h" > >static apr_bucket_brigade *make_brigade(apr_pool_t *p, apr_bucket_alloc_t *ba, const char *str) >{ > apr_bucket_brigade *bb = apr_brigade_create(p, ba); > apr_bucket *e; > > e = apr_bucket_transient_create(str, strlen(str), ba); > APR_BRIGADE_INSERT_TAIL(bb, e); > return bb; >} > >static void brigade_dump(const char *ctx, apr_bucket_brigade *bb) >{ > int idx = 0; > apr_bucket *e; > > if (APR_BRIGADE_EMPTY(bb)) { > printf("%s brigade empty\n", ctx); > return; > } > for (e = APR_BRIGADE_FIRST(bb); e != APR_BRIGADE_SENTINEL(bb); e = APR_BUCKET_NEXT(e)) { > printf("%s bucket %02d: start %d length %d %s\n", ctx, idx, (int)e->start, (int)e->length, (e->length == 0) ? "IS_EMPTY!" : ""); > idx++; > } >} > >static void test_splitline(apr_pool_t *p, const char *str) >{ > apr_status_t rv; > apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p); > apr_bucket_brigade *bin, *bout; > > printf("test {{{%s}}}:\n", str); > bin = make_brigade(p, ba, str); > bout = apr_brigade_create(p, ba); > > rv = apr_brigade_split_line(bout, bin, APR_BLOCK_READ, 8000); > assert(rv == APR_SUCCESS); > > brigade_dump(" in", bin); > brigade_dump("out", bout); > > apr_brigade_destroy(bout); > apr_brigade_destroy(bin); > apr_bucket_alloc_destroy(ba); >} > >int main(int ac, char *av[]) >{ > apr_pool_t *p; > apr_status_t rv; > > rv = apr_initialize(); > assert(rv == APR_SUCCESS); > atexit(apr_terminate); > apr_pool_create(&p, NULL); > > test_splitline(p, "aa aa\nbb bb"); > test_splitline(p, "aa aa\n"); > return 0; >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 64273
:
37128
|
37129
| 37130