From: Takashi Sakamoto Date: Wed, 22 Jun 2022 03:05:26 +0000 (+0900) Subject: utils: successfully parse the string teminated by '\n' X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=3ebe00cf51a0af27977e969d0eca31f3df9dec32;p=alsa-gobject.git 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 --- 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;