From 85ae0e1b52487adfe8f06509f5e02bc089d3702e Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 19 Sep 2023 06:34:26 -0500 Subject: [PATCH] Michael Shavit pointed out strtoul->strtoull and requested checking errno (presumably to catch overflow that doesn't leave unconsumed digits). --- toys/other/devmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/toys/other/devmem.c b/toys/other/devmem.c index 4d558fb4..137e60c4 100644 --- a/toys/other/devmem.c +++ b/toys/other/devmem.c @@ -20,9 +20,11 @@ config DEVMEM unsigned long long atollu(char *str) { char *end = str; - unsigned long long llu = strtoul(str, &end, 0); + unsigned long long llu; - if (*end) error_exit("bad %s", str); + errno = 0; + llu = strtoull(str, &end, 0); + if (*end || errno) perror_exit("bad %s", str); return llu; } -- 2.39.2