Control: tags -1 patch Hi!
On Sun, 2024-08-04 at 12:24:24 +0300, Adrian Bunk wrote: > Source: ledmon > Version: 0.97-1.1 > Severity: serious > Tags: ftbfs > https://buildd.debian.org/status/logs.php?pkg=ledmon&ver=0.97-1.1 > > ... > utils.c: In function ‘get_uint64’: > utils.c:105:18: error: passing argument 1 of ‘str_toul’ from incompatible > pointer type [-Wincompatible-pointer-types] > 105 | str_toul(&defval, p, NULL, 16); > | ^~~~~~~ > | | > | uint64_t * {aka long long unsigned int *} > In file included from utils.c:48: > utils.h:368:29: note: expected ‘long unsigned int *’ but argument is of type > ‘uint64_t *’ {aka ‘long long unsigned int *’} > 368 | int str_toul(unsigned long *dest, const char *strptr, char **endptr, > int base); > | ~~~~~~~~~~~~~~~^~~~ > ... The attached patch, adapted from an upstream commit, should fix this issue on 32-bit arches (tested on an i386 chroot). Personally I'm not very fond of the "unsigned" strtou*() functions, but given that upstream went this way, this seems like the less intrusive path. Thanks, Guillem
From ed747ac3540cb38797f56533f9f51f5627e6b994 Mon Sep 17 00:00:00 2001 From: Tony Asleson <tasle...@redhat.com> 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 <tasle...@redhat.com> Origin: upstream, commit:ed747ac3540cb38797f56533f9f51f5627e6b994 Applied-Upstream: 1.0.0+ Bug-Debian: https://bugs.debian.org/1077904 Forwarded: not-needed Last-Update: 2024-09-16 --- src/utils.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/src/utils.c +++ b/src/utils.c @@ -102,9 +102,13 @@ uint64_t get_uint64(const char *path, ui 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)