[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for-3.0] slirp: Correct size check in m_inc()
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH for-3.0] slirp: Correct size check in m_inc() |
Date: |
Fri, 10 Aug 2018 10:02:37 +0100 |
On 9 August 2018 at 22:54, Samuel Thibault <address@hidden> wrote:
> Dr. David Alan Gilbert, le jeu. 09 août 2018 12:32:05 +0100, a ecrit:
>> > |--datasize---->|---m_len------->
>> > |----------m_size------------------------------>
>> > |----M_ROOM-------------------->
>> > |-M_FREEROOM-->
>> >
>> > ^ ^ ^
>> > m_dat m_data end of buffer
>> >
>> > ("datasize" is a bit misnamed, as it's "size of the leading
>> > gap between the start of the buffer and the data"; "gapsize"
>> > would be more helpful.)
>> >
>> > Anyway, we allocate size + datasize, and
>> > m_size == datasize + M_ROOM. We know that size >= M_ROOM,
>> > so the allocated buffer must be at least m_size big.
>>
>> Ah OK, thanks.
>> (That ascii art could do with being in a comment somewhere!)
>
> Indeed. Peter, maybe your Signed-off-by on this? :)
Signed-off-by: Peter Maydell <address@hidden>
> Samuel
>
> commit 4be85a1eeb6b19e91491e689d4d0d054030cbb49
> Author: Peter Maydell <address@hidden>
> Date: Thu Aug 9 23:52:59 2018 +0200
>
> slirp: document mbuf pointers and sizes
>
> Signed-off-by: Samuel Thibault <address@hidden>
>
> diff --git a/slirp/mbuf.h b/slirp/mbuf.h
> index 33b84485d6..a5bb3f9e66 100644
> --- a/slirp/mbuf.h
> +++ b/slirp/mbuf.h
> @@ -47,6 +47,16 @@
> * free the m_ext. This is inefficient memory-wise, but who cares.
> */
>
> +/*
> + * |--gapsize----->|---m_len------->
> + * |----------m_size------------------------------>
> + * |----M_ROOM-------------------->
> + * |-M_FREEROOM-->
> + *
> + * ^ ^ ^
> + * m_dat/m_ext m_data end of buffer
> + */
> +
...but
(a) you should add a comment describing what 'gapsize'
is, ie that there may be a gap between the in-use data and the
start of the allocated buffer, and
(b) m_inc() should change its variable name to match.
thanks
-- PMM
- Re: [Qemu-devel] [PATCH for-3.0] slirp: Correct size check in m_inc(), (continued)
- Re: [Qemu-devel] [PATCH for-3.0] slirp: Correct size check in m_inc(), Thomas Huth, 2018/08/07
- Re: [Qemu-devel] [PATCH for-3.0] slirp: Correct size check in m_inc(), Daniel P . Berrangé, 2018/08/07
- Re: [Qemu-devel] [PATCH for-3.0] slirp: Correct size check in m_inc(), Peter Maydell, 2018/08/07
- Re: [Qemu-devel] [PATCH for-3.0] slirp: Correct size check in m_inc(), Markus Armbruster, 2018/08/07
- Re: [Qemu-devel] [PATCH for-3.0] slirp: Correct size check in m_inc(), Peter Maydell, 2018/08/07
Re: [Qemu-devel] [PATCH for-3.0] slirp: Correct size check in m_inc(), Peter Maydell, 2018/08/07
Re: [Qemu-devel] [PATCH for-3.0] slirp: Correct size check in m_inc(), Dr. David Alan Gilbert, 2018/08/09