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

Patrick DELAUNAY patrick.delaunay at foss.st.com
Tue Nov 12 11:51:12 CET 2024


Hi,

On 11/3/24 23:42, Heinrich Schuchardt wrote:
> hextoul() cannot convert a string to a 64-bit number on a 32-bit system.
> Use function hextoull() instead.
>
> Reported-by: Patrick Delaunay <patrick.delaunay at foss.st.com>
> Fixes: 22c48a92cdce ("lib: uuid: supporting building as part of host tools")
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
> v2:
> 	no change
> ---
>   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;


Tested-by: Patrick Delaunay <patrick.delaunay at foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay at foss.st.com>


Thanks.
Patrick


With the series the regression is solved on STM32MP15 board.


tested  on STM32MP15C-DK2 / 2025.01-rc2


the GPT partitions create with GPT common, create with stm32prog 
command,  are

limited a first bytes, after the patch we have the correct UUID 
(partition or type):


before the patch:


STM32MP>partlistmmc0
PartitionMapformmcdevice0--PartitionType:EFI
PartStartLBAEndLBAName
Attributes
TypeGUID
PartitionGUID
10x000000220x00000221"fsbl1"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-0000c8230908
(8da63339-0007-60c0-c436-0000c8230908)
guid:4a75790f-e291-441b-9637-0000165411b2
20x000002220x00000421"fsbl2"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-0000c8230908
(8da63339-0007-60c0-c436-0000c8230908)
guid:7a1e006d-bd4a-42b7-a725-000012451e59
30x000004220x00000621"metadata1"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-0000c8230908
(8da63339-0007-60c0-c436-0000c8230908)
guid:2ead27e5-8fc8-4e00-a0c8-00005d7a437c
40x000006220x00000821"metadata2"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-0000c8230908
(8da63339-0007-60c0-c436-0000c8230908)
guid:2d2536b7-6420-4401-90b0-0000831b3a72
50x000008220x00002821"fip-a"
attrs:0x0000000000000000
type:19d5df83-11b0-457b-be2c-0000c13142a5
(19d5df83-11b0-457b-be2c-0000c13142a5)
guid:4fd84c93-54ef-463f-a7ef-0000ff887087
60x000028220x00004821"fip-b"
attrs:0x0000000000000000
type:19d5df83-11b0-457b-be2c-0000c13142a5
(19d5df83-11b0-457b-be2c-0000c13142a5)
guid:09c54952-d5bf-45af-acee-000003766fb3
70x000048220x00004c21"u-boot-env"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-0000c8230908
(8da63339-0007-60c0-c436-0000c8230908)
guid:514446c6-d705-40d7-aa4b-0000a95a0379
80x00004c220x00024c21"bootfs"
attrs:0x0000000000000004
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:22e8efa0-375c-4be0-99ce-00000172479f
90x00024c220x0002cc21"vendorfs"
attrs:0x0000000000000000
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:e1e3f6f9-a4f5-4094-9622-000042c3bcd7
100x0002cc220x0019cc21"rootfs"
attrs:0x0000000000000000
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:e91c4e10-16e6-4c0e-bd0e-0000cf4a3582
110x0019cc220x0ee2afdc"userfs"
attrs:0x0000000000000000
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:3d14d2bf-7798-4c57-865a-00007ac4cd0c
==================
after the series :
==================
STM32MP>partlistmmc0
PartitionMapformmcdevice0--PartitionType:EFI
PartStartLBAEndLBAName
Attributes
TypeGUID
PartitionGUID
10x000000220x00000221"fsbl1"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-083ac8230908
(8da63339-0007-60c0-c436-083ac8230908)
guid:bcf89b85-baba-4cab-b776-27b7e3eade64
20x000002220x00000421"fsbl2"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-083ac8230908
(8da63339-0007-60c0-c436-083ac8230908)
guid:0b5c4320-aa24-4133-a08b-99f59ec2405b
30x000004220x00000621"metadata1"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-083ac8230908
(8da63339-0007-60c0-c436-083ac8230908)
guid:264a01cf-84d9-4a2e-810f-86cc3617aba0
40x000006220x00000821"metadata2"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-083ac8230908
(8da63339-0007-60c0-c436-083ac8230908)
guid:187a929a-f00e-436f-a635-8ccbf2a532e8
50x000008220x00002821"fip-a"
attrs:0x0000000000000000
type:19d5df83-11b0-457b-be2c-7559c13142a5
(19d5df83-11b0-457b-be2c-7559c13142a5)
guid:4fd84c93-54ef-463f-a7ef-ae25ff887087
60x000028220x00004821"fip-b"
attrs:0x0000000000000000
type:19d5df83-11b0-457b-be2c-7559c13142a5
(19d5df83-11b0-457b-be2c-7559c13142a5)
guid:09c54952-d5bf-45af-acee-335303766fb3
70x000048220x00004c21"u-boot-env"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-083ac8230908
(8da63339-0007-60c0-c436-083ac8230908)
guid:2667f0f0-acfc-4f7e-81b8-5da24fc7efbe
80x00004c220x00024c21"bootfs"
attrs:0x0000000000000004
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:9fedf49a-bcc9-46ef-b40c-bbe42e138c23
90x00024c220x0002cc21"vendorfs"
attrs:0x0000000000000000
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:d0633872-d1c2-49b6-b81a-2744c4617148
100x0002cc220x0019cc21"rootfs"
attrs:0x0000000000000000
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:e91c4e10-16e6-4c0e-bd0e-77becf4a3582
110x0019cc220x0ee2afdc"userfs"
attrs:0x0000000000000000
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:8e049511-8c1d-4791-bf37-f2365101a073




More information about the U-Boot mailing list