diff options
author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2018-03-14 19:51:28 +0000 |
---|---|---|
committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2018-03-14 19:51:28 +0000 |
commit | cbfc3c73cea627645905287be8213ff029625274 (patch) | |
tree | cfd73f31df01cb4eefca462f3fd5cc514485d764 /sys/compat/linuxkpi/common/include/linux/kernel.h | |
parent | cfeecda0a9b4fa43827226ceb00b6e041ad300e8 (diff) | |
download | src-cbfc3c73cea627645905287be8213ff029625274.tar.gz src-cbfc3c73cea627645905287be8213ff029625274.zip |
Fix compliancy of the kstrtoXXX() functions in the LinuxKPI, by skipping
one newline character at the end, if any.
Found by: greg@unrelenting.technology
MFC after: 1 week
Sponsored by: Mellanox Technologies
Notes
Notes:
svn path=/head/; revision=330944
Diffstat (limited to 'sys/compat/linuxkpi/common/include/linux/kernel.h')
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/kernel.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index 0f34595599f4..edfa50e201ae 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -295,6 +295,9 @@ kstrtoul(const char *cp, unsigned int base, unsigned long *res) *res = strtoul(cp, &end, base); + /* skip newline character, if any */ + if (*end == '\n') + end++; if (*cp == 0 || *end != 0) return (-EINVAL); return (0); @@ -307,6 +310,9 @@ kstrtol(const char *cp, unsigned int base, long *res) *res = strtol(cp, &end, base); + /* skip newline character, if any */ + if (*end == '\n') + end++; if (*cp == 0 || *end != 0) return (-EINVAL); return (0); @@ -320,6 +326,9 @@ kstrtoint(const char *cp, unsigned int base, int *res) *res = temp = strtol(cp, &end, base); + /* skip newline character, if any */ + if (*end == '\n') + end++; if (*cp == 0 || *end != 0) return (-EINVAL); if (temp != (int)temp) @@ -335,6 +344,9 @@ kstrtouint(const char *cp, unsigned int base, unsigned int *res) *res = temp = strtoul(cp, &end, base); + /* skip newline character, if any */ + if (*end == '\n') + end++; if (*cp == 0 || *end != 0) return (-EINVAL); if (temp != (unsigned int)temp) @@ -350,6 +362,9 @@ kstrtou32(const char *cp, unsigned int base, u32 *res) *res = temp = strtoul(cp, &end, base); + /* skip newline character, if any */ + if (*end == '\n') + end++; if (*cp == 0 || *end != 0) return (-EINVAL); if (temp != (u32)temp) |