[PATCH v1 2/2] test: env: add test for himport_r SIZE_MAX overflow guard

Simon Glass sjg at chromium.org
Sat Apr 11 19:39:24 CEST 2026


Hi Aristo,

On 2026-04-08T14:03:35, Aristo Chen <aristo.chen at canonical.com> wrote:
> test: env: add test for himport_r SIZE_MAX overflow guard
>
> Add a unit test that verifies himport_r rejects SIZE_MAX as the size
> argument, ensuring the integer overflow guard added to lib/hashtable.c
> is exercised and not accidentally regressed.
>
> Signed-off-by: Aristo Chen <aristo.chen at canonical.com>
>
> test/env/hashtable.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)

> diff --git a/test/env/hashtable.c b/test/env/hashtable.c
> @@ -122,3 +122,20 @@ static int env_test_htab_deletes(struct unit_test_state *uts)
> +     /* SIZE_MAX would cause malloc(size + 1) to wrap to malloc(0) */
> +     ut_asserteq(0, himport_r(&htab, "", SIZE_MAX, '\0', 0, 0, 0, NULL));

Please can you add a check that errno is set to EINVAL after the
himport_r() call?

It's a pretty old API that!

Reviewed-by: Simon Glass <sjg at chromium.org>

Regards,
Simon


More information about the U-Boot mailing list