On 08.09.25 10:35, Quirin Gylstorff wrote:
> From: Quirin Gylstorff <[email protected]>
> 
> This fixes the following error with gcc-15:
> 
> In function 'bgenv_get_uint',
>     inlined from 'bgenv_get' at env/env_api_fat.c:360:10:
> env/env_api_fat.c:296:9: error: 'strncpy' output may be truncated copying 
> between 2 and 4 bytes from a string of length 254 
> [-Werror=stringop-truncation]
>   296 |         strncpy(data, buffer, res+1);
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> As sprintf adds already a null-terminator and data is a void pointer
> we can use memcpy directly.
> 
> Signed-off-by: Quirin Gylstorff <[email protected]>
> ---
>  env/env_api_fat.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/env/env_api_fat.c b/env/env_api_fat.c
> index 7c84dc6..b409d45 100644
> --- a/env/env_api_fat.c
> +++ b/env/env_api_fat.c
> @@ -293,7 +293,7 @@ static int bgenv_get_uint(char *buffer, uint64_t *type, 
> void *data,
>       if (!data) {
>               return res+1;
>       }
> -     strncpy(data, buffer, res+1);
> +     memcpy(data, buffer, res+1);
>       if (type) {
>               *type = t;
>       }

Thanks, applied.

The APIs of bgenv_get_uint/string need some refactoring, independently
of this...

Jan

-- 
Siemens AG, Foundational Technologies
Linux Expert Center

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/efibootguard-dev/dffd6264-dcae-4a9a-b6cc-75447830be34%40siemens.com.

Reply via email to