[PATCH 2/3] lib: uuid: fix uuid_str_to_le_bin() on 32-bit

Tom Rini trini at konsulko.com
Sun Nov 3 16:48:44 CET 2024


On Sun, Nov 03, 2024 at 08:11:59AM +0100, Heinrich Schuchardt wrote:

> hextoul() cannot convert a string to a 64-bit number on a 32-bit system.
> Use function hextoull() instead.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>

Reported-by: Patrick Delaunay <patrick.delaunay at foss.st.com>
Fixes: 22c48a92cdce ("lib: uuid: supporting building as part of host tools")

> ---
>  lib/uuid.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/uuid.c b/lib/uuid.c
> index c6a27b7d044..19f33dd1477 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -35,6 +35,7 @@
>  #ifdef USE_HOSTCC
>  /* polyfill hextoul to avoid pulling in strto.c */
>  #define hextoul(cp, endp) strtoul(cp, endp, 16)
> +#define hextoull(cp, endp) strtoull(cp, endp, 16)
>  #endif
>  
>  int uuid_str_valid(const char *uuid)
> @@ -339,7 +340,7 @@ int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
>  	tmp16 = cpu_to_le16(hextoul(uuid_str + 19, NULL));
>  	memcpy(uuid_bin + 8, &tmp16, 2);
>  
> -	tmp64 = cpu_to_le64(hextoul(uuid_str + 24, NULL));
> +	tmp64 = cpu_to_le64(hextoull(uuid_str + 24, NULL));
>  	memcpy(uuid_bin + 10, &tmp64, 6);
>  
>  	return 0;
> -- 
> 2.45.2
> 

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20241103/3d0551d7/attachment.sig>


More information about the U-Boot mailing list