strict_strto* is not strict enough
Subsystems (2)
It decodes "\n" as 0, which is bad, because stray echo into backlight will turn your backlight off, etc...
Signed-off-by Pavel Machek <[email protected]>
lib/vsprintf.c +4 -0
@@ -170,6 +170,8 @@ int strict_strtoul(const char *cp, unsigreturn -EINVAL ; val =simple_strtoul (cp, &tail, base); +if (tail == cp) +return -EINVAL ;if ((*tail =='\0' ) || ((len == (size_t )(tail - cp) +1 ) && (*tail =='\n' ))) { *res = val;
@@ -241,6 +243,8 @@ int strict_strtoull(const char *cp, unsireturn -EINVAL ; val =simple_strtoull (cp, &tail, base); +if (tail == cp) +return -EINVAL ;if ((*tail =='\0' ) || ((len == (size_t )(tail - cp) +1 ) && (*tail =='\n' ))) { *res = val;
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html