Hi Raymond, On Fri, 22 Dec 2023 at 17:30, Raymond Mao <raymond....@linaro.org> wrote: > > Hi Ilias, > > On Fri, 22 Dec 2023 at 06:12, Ilias Apalodimas <ilias.apalodi...@linaro.org> > wrote: >> >> Hi Raymond, >> >> On Thu, 21 Dec 2023 at 02:41, Raymond Mao <raymond....@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....@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 ? Thanks /Ilias > >> - * @to_size: New size for bloblist (must be larger than from_size) > I will refactor this part. > >> >> > + hdr->total_size = gd->bloblist->total_size; >> > + else >> > + hdr->total_size = to_size; >> > + gd->bloblist = to; >> > } >> > >> > int bloblist_init(void) >> > diff --git a/common/board_f.c b/common/board_f.c >> > index d4d7d01f8f..00b0430889 100644 >> > --- a/common/board_f.c >> >> [...] >> >> /Ilias