[PATCH 12/12] test/ipsec: fix build with GCC 12
Bruce Richardson
bruce.richardson at intel.com
Fri Jun 3 09:56:03 CEST 2022
On Fri, Jun 03, 2022 at 09:45:45AM +0200, David Marchand wrote:
> Hello Vladimir,
>
> On Thu, Jun 2, 2022 at 8:42 PM Medvedkin, Vladimir
> <vladimir.medvedkin at intel.com> wrote:
> > > if (!dst) {
> > > rte_pktmbuf_free(m);
> > > return NULL;
> > > }
> > > - if (string != NULL)
> > > - rte_memcpy(dst, string, t_len);
> > > - else
> > > - memset(dst, 0, t_len);
> > > + if (string != NULL) {
> > > + size_t off;
> > > +
> > > + for (off = 0; off + string_len < len; off += string_len)
> >
> > I think it should be off + string_len <= len here, because otherwise, if
> > len is a multiple of string_len, the last ret_memcpy (after this loop)
> > will copy 0 bytes.
>
> Changing to off + string_len <= len would trigger an oob access to dst
> (by one extra byte)?
> Otoh, I don't think it is an issue to have a 0-length call to rte_memcpy.
>
Given this is test code, do we need rte_memcpy for performance over regular
libc memcpy? Does fixing the warning become any easier or clearer if libc
memcpy is used?
More information about the stable
mailing list