[PATCH v2 3/9] bloblist: refactor of bloblist_reloc()

Raymond Mao raymond.mao at linaro.org
Fri Dec 22 17:34:51 CET 2023


Hi Ilias,

On Fri, 22 Dec 2023 at 10:46, Ilias Apalodimas <ilias.apalodimas at linaro.org>
wrote:

> Hi Raymond,
>
> On Fri, 22 Dec 2023 at 17:30, Raymond Mao <raymond.mao at linaro.org> wrote:
> >
> > Hi Ilias,
> >
> > On Fri, 22 Dec 2023 at 06:12, Ilias Apalodimas <
> ilias.apalodimas at linaro.org> wrote:
> >>
> >> Hi Raymond,
> >>
> >> On Thu, 21 Dec 2023 at 02:41, Raymond Mao <raymond.mao at linaro.org>
> wrote:
> >> >
> >> > The current bloblist pointer and size can be retrieved from global
> >> > data, so we don't need to pass them from the function arguments.
> >> > This change also help to remove all external access of gd->bloblist
> >> > outside of bloblist module.
> >> >
> >> > Signed-off-by: Raymond Mao <raymond.mao at linaro.org>
> >> > ---
> >>
> >> [...]
> >>
> >> >         }
> >> >  }
> >> >
> >> > -void bloblist_reloc(void *to, uint to_size, void *from, uint
> from_size)
> >> > +void bloblist_reloc(void *to, uint to_size)
> >> >  {
> >> >         struct bloblist_hdr *hdr;
> >> >
> >> > -       memcpy(to, from, from_size);
> >> > +       memcpy(to, gd->bloblist, gd->bloblist->total_size);
> >> >         hdr = to;
> >> > -       hdr->total_size = to_size;
> >> > +       if (to_size < gd->bloblist->total_size)
> >>
> >> What's the size of *to? Is it equal to to_size?
> >> Because if to_size can be smaller that gd->bloblist->total_size the
> >> memcpy above is wrong
> >
> > to_size should be 0 (use the total_size) or a value larger than
> total_size.
> > I think I should keep the below line from the function header.
>
> The point here is, are we certain that the *to is big enough? Or we'll
> end up overflowing ?
>
Yes, this needs to be checked before copying.

Thanks and regards,
Raymond


More information about the U-Boot mailing list