lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20191209174248.45342-2-andriy.shevchenko@linux.intel.com>
Date:   Mon,  9 Dec 2019 19:42:48 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
        linux-kernel@...r.kernel.org
Cc:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v1 2/2] x86/mtrr: Use strstrip() to cut extra spaces

Cut all white spaces surrounding the passed line.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
 arch/x86/kernel/cpu/mtrr/if.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c
index a51eb8e4c079..9d251efdf064 100644
--- a/arch/x86/kernel/cpu/mtrr/if.c
+++ b/arch/x86/kernel/cpu/mtrr/if.c
@@ -97,10 +97,9 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
 	int i, err;
 	unsigned long reg;
 	unsigned long long base, size;
-	char *ptr;
+	char *ptr, *l;
 	char line[LINE_SIZE];
 	int length;
-	size_t linelen;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
@@ -112,23 +111,20 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
 	if (length < 0)
 		return length;
 
-	linelen = strlen(line);
-	ptr = line + linelen - 1;
-	if (linelen && *ptr == '\n')
-		*ptr = '\0';
+	l = strstrip(line);
 
-	if (!strncmp(line, "disable=", 8)) {
-		reg = simple_strtoul(line + 8, &ptr, 0);
+	if (!strncmp(l, "disable=", 8)) {
+		reg = simple_strtoul(l + 8, &ptr, 0);
 		err = mtrr_del_page(reg, 0, 0);
 		if (err < 0)
 			return err;
 		return len;
 	}
 
-	if (strncmp(line, "base=", 5))
+	if (strncmp(l, "base=", 5))
 		return -EINVAL;
 
-	base = simple_strtoull(line + 5, &ptr, 0);
+	base = simple_strtoull(l + 5, &ptr, 0);
 	ptr = skip_spaces(ptr);
 
 	if (strncmp(ptr, "size=", 5))
-- 
2.24.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ