Hallo Harald,
On 6/2/26 14:05, Harald Brinkmann wrote:
> This prevents leaking leftover heap data into the end of the environment.
>
> Signed-off-by: Harald Brinkmann <
brin...@stulz-digital-solutions.com>
> ---
> src/uboot_env.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/uboot_env.c b/src/uboot_env.c
> index 96d23bf..3121a52 100644
> --- a/src/uboot_env.c
> +++ b/src/uboot_env.c
> @@ -526,10 +526,13 @@ int libuboot_env_store(struct uboot_ctx *ctx)
> /*
> * Allocate the bigger of the case
> */
> - image = malloc(sizeof(struct uboot_env_redund) + ctx->size);
> + size = sizeof(struct uboot_env_redund) + ctx->size;
> + image = malloc(size);
> if (!image)
> return -ENOMEM;
>
> + memset(image, 0, size);
> +
It is not very clear to me which is the issue. The only change is that
the data is zeroed. But on the other side, this is on the heap, the
exact amount of written data is when devwrite() is called, and after
that this temporary storage is freed.
Which is the issue ?
Best regards,
Stefano Babic
> if (ctx->redundant)
> offsetdata = offsetof(struct uboot_env_redund, data);
> else
> --
> 2.53.0
>
> Sitz der Gesellschaft: Hamburg Amtsgericht Hamburg | HRB 172947 Geschäftsführer: Markus Trautwein, Thorsten Weiß
>
--
_______________________________________________________________________
Nabla Software Engineering GmbH
Hirschstr. 111A | 86156 Augsburg | Tel:
+49 821 45592596
Geschäftsführer : Stefano Babic | HRB 40522 Augsburg
E-Mail:
sba...@nabladev.com