Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Mar 2018 18:51:36 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r331799 - stable/11/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201803301851.w2UIpaWJ085324@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Fri Mar 30 18:51:36 2018
New Revision: 331799
URL: https://svnweb.freebsd.org/changeset/base/331799

Log:
  MFC r330944:
  Fix compliancy of the kstrtoXXX() functions in the LinuxKPI, by skipping
  one newline character at the end, if any.
  
  Found by:	greg@unrelenting.technology
  Sponsored by:	Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/kernel.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/kernel.h
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/include/linux/kernel.h	Fri Mar 30 18:50:42 2018	(r331798)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/kernel.h	Fri Mar 30 18:51:36 2018	(r331799)
@@ -295,6 +295,9 @@ kstrtoul(const char *cp, unsigned int base, unsigned l
 
 	*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
 
 	*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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803301851.w2UIpaWJ085324>