Re: apr_bucket_split data remains

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 2, 2018 at 6:45 AM, Simon Walter <simon@xxxxxxxxxx> wrote:
> Yes, thanks for looking at it, Eric. It is correct after I flatten it:
>
> output:
> _ASCII_String0_!__ASCII_String4_!ASCII_String1_!_ASCII_String2_!_ASCII_String3_!
>
> but not when reading the bucket with apr_bucket_read(Index, &TestBuffer,
> &Length, APR_BLOCK_READ):
>
> Marker: 1
> CurrBucket: _ASCII_String1_!
> Length: 1
>
> Bucket1 is not just "_".

Sorry, I lost track of the pre/post flatten aspect.

> It looks like apr_bucket_read returns the memory location of the
> original string and does no manipulation like null termination when
> splitting.


> So I guess that I cannot simply call printf, and that I must either use
> putchar with a loop or snprintf, strncpy, memcpy, etc.

Ah yes, that makes sense.  See for example what very little happens
when you split or read from a heap bucket:

APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_split(apr_bucket *a,
                                                        apr_size_t point)
{
   apr_bucket *b;

   if (point > a->length) {
       return APR_EINVAL;
   }

   apr_bucket_simple_copy(a, &b);

   a->length  = point;
   b->length -= point;
   b->start  += point;

   APR_BUCKET_INSERT_AFTER(a, b);

   return APR_SUCCESS;
}


static apr_status_t heap_bucket_read(apr_bucket *b, const char **str,
                                    apr_size_t *len, apr_read_type_e block)
{
   apr_bucket_heap *h = b->data;

   *str = h->base + b->start;
   *len = b->length;
   return APR_SUCCESS;
}


For the transient bucket query, you could try allocating the strings
on the stack, then return and try to read them (without using string
literals or strdup to potentially confuse things)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux