From f8bdb6c7f42da6e3162a2adbe6780f34140c04da Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Wed, 22 Jun 2022 12:05:26 +0900 Subject: [PATCH] utils: successfully parse the string teminated by '\n' It requires to parse the literal from sysfs node. Fixes: cc92f5ca9478 ("utils: add utility to compute integer value from string literal") Signed-off-by: Takashi Sakamoto --- src/utils/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/string.c b/src/utils/string.c index fe0ab13..f04fb95 100644 --- a/src/utils/string.c +++ b/src/utils/string.c @@ -13,7 +13,7 @@ long long_from_string(const char *literal, long *number) val = strtol(literal, &endptr, 10); if (errno > 0) return -errno; - if (!endptr || endptr == literal || *endptr != 0) + if (!endptr || endptr == literal || (*endptr != 0 && *endptr != '\n')) return -EINVAL; *number = val; return 0; -- 2.47.3