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-next>] [day] [month] [year] [list]
Message-Id: <20190729151454.9606-1-hslester96@gmail.com>
Date:   Mon, 29 Jul 2019 23:14:54 +0800
From:   Chuhong Yuan <hslester96@...il.com>
To:     unlisted-recipients:; (no To-header on input)
Cc:     "Rafael J . Wysocki" <rjw@...ysocki.net>,
        Pavel Machek <pavel@....cz>, Len Brown <len.brown@...el.com>,
        linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        Chuhong Yuan <hslester96@...il.com>
Subject: [PATCH 07/12] power: Replace strncmp with str_has_prefix

strncmp(str, const, len) is error-prone.
We had better use newly introduced
str_has_prefix() instead of it.

Signed-off-by: Chuhong Yuan <hslester96@...il.com>
---
 kernel/power/hibernate.c | 8 ++++----
 kernel/power/main.c      | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index cd7434e6000d..49d4bfdb2b67 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -1188,15 +1188,15 @@ static int __init resume_offset_setup(char *str)
 
 static int __init hibernate_setup(char *str)
 {
-	if (!strncmp(str, "noresume", 8)) {
+	if (str_has_prefix(str, "noresume")) {
 		noresume = 1;
-	} else if (!strncmp(str, "nocompress", 10)) {
+	} else if (str_has_prefix(str, "nocompress")) {
 		nocompress = 1;
-	} else if (!strncmp(str, "no", 2)) {
+	} else if (str_has_prefix(str, "no")) {
 		noresume = 1;
 		nohibernate = 1;
 	} else if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX)
-		   && !strncmp(str, "protect_image", 13)) {
+		   && str_has_prefix(str, "protect_image")) {
 		enable_restore_image_protection();
 	}
 	return 1;
diff --git a/kernel/power/main.c b/kernel/power/main.c
index bdbd605c4215..5e5f64bb3a43 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -495,7 +495,7 @@ static suspend_state_t decode_state(const char *buf, size_t n)
 	len = p ? p - buf : n;
 
 	/* Check hibernation first. */
-	if (len == 4 && !strncmp(buf, "disk", len))
+	if (len == 4 && str_has_prefix(buf, "disk"))
 		return PM_SUSPEND_MAX;
 
 #ifdef CONFIG_SUSPEND
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ