diff --git a/meta-oe/recipes-bsp/ledmon/ledmon/Correct-get_uint64.patch b/meta-oe/recipes-bsp/ledmon/ledmon/Correct-get_uint64.patch new file mode 100644 index 0000000000..c4d8ff80b8 --- /dev/null +++ b/meta-oe/recipes-bsp/ledmon/ledmon/Correct-get_uint64.patch @@ -0,0 +1,44 @@ +From ed747ac3540cb38797f56533f9f51f5627e6b994 Mon Sep 17 00:00:00 2001 +From: Tony Asleson +Date: Wed, 21 Aug 2024 12:27:28 -0500 +Subject: [PATCH] Correct get_uint64 + +For large integer values, the existing implementation will be +incorrect. + +The current implementation of converting strings to integer values +uses a signed integer for the intermediate conversion and performs +a range check. Since any value in an unsigned 64-bit integer is valid, +the range check seems unnecessary. To mimic the same code path, we would +need a larger integer type. + +Signed-off-by: Tony Asleson + +Upstream-Status: Backport [https://github.com/intel/ledmon/commit/ed747ac3540cb38797f56533f9f51f5627e6b994] + +Signed-off-by: Gyorgy Sarvari +--- + src/utils.c | 9 ++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/utils.c b/src/utils.c +index 86b9593..b87d064 100644 +--- a/src/utils.c ++++ b/src/utils.c +@@ -102,9 +102,14 @@ uint64_t get_uint64(const char *path, uint64_t defval, const char *name) + if (!p) + return defval; + +- str_toul(&defval, p, NULL, 16); ++ errno = 0; ++ uint64_t t = strtoull(p, NULL, 16); + free(p); +- return defval; ++ ++ if (errno) ++ return defval; ++ ++ return t; + } + + int get_int(const char *path, int defval, const char *name) diff --git a/meta-oe/recipes-bsp/ledmon/ledmon_0.97.bb b/meta-oe/recipes-bsp/ledmon/ledmon_0.97.bb index 88a6e5bb30..23a49a7d1b 100644 --- a/meta-oe/recipes-bsp/ledmon/ledmon_0.97.bb +++ b/meta-oe/recipes-bsp/ledmon/ledmon_0.97.bb @@ -16,7 +16,8 @@ SYSTEMD_SERVICE:${PN} = "ledmon.service" SRC_URI = "git://github.com/intel/ledmon;branch=master;protocol=https \ file://0002-include-sys-select.h-and-sys-types.h.patch \ - file://0001-fix-build-with-clang.patch" + file://0001-fix-build-with-clang.patch \ + file://Correct-get_uint64.patch" SRCREV = "b0edae14e8660b80ffe0384354038a9f62e2978d"