]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
lib: uuid: fix uuid_str_to_le_bin() on 32-bit
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 3 Nov 2024 22:42:21 +0000 (23:42 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 13 Nov 2024 14:14:23 +0000 (08:14 -0600)
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@foss.st.com>
Fixes: 22c48a92cdce ("lib: uuid: supporting building as part of host tools")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
Tested-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
lib/uuid.c

index c6a27b7d044dfb5b2116893fc538919a6318e701..19f33dd147768a5b05edad78199e04297a7d9659 100644 (file)
@@ -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;