[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: memcpy on overlapping memory
From: |
Mark Esler |
Subject: |
Re: memcpy on overlapping memory |
Date: |
Wed, 24 Aug 2022 13:33:50 -0500 |
Hi Bruno,
Thank you for explaining how those buffers work.
Best regards,
Mark Esler
On Fri, Aug 19, 2022 at 11:26 PM Bruno Haible <bruno@clisp.org> wrote:
>
> Mark Esler wrote:
> > I believe Gnulib contains memcpy calls on overlapping memory and that
> > commit 3e7178b337e3a83df9e4f36a4aef516f089e3796 was incomplete.
> >
> > Please see https://gitlab.com/gsasl/gsasl/-/issues/4 for details.
>
> The comment from [1] is correct.
>
> Your statement "If left_over >= 16, memcpy will overwrite the source
> as it is being copied." is incorrect.
>
> ctx->buffer and &ctx->buffer[16] differ by 16 units, each unit being
> uint32_t, that is 4 bytes wide. So these pointers differ by 64 bytes.
> Since left_over ≤ 64, there is no overlap.
>
> Bruno
>
> [1]
> https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=3e7178b337e3a83df9e4f36a4aef516f089e3796
>
>
>