From: Herbert Xu <herbert@gondor.apana.org.au>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>,
mochel@osdl.org
Subject: [PMDISK] Fix strcmp in sysfs store
Date: Mon, 22 Mar 2004 00:11:09 +1100 [thread overview]
Message-ID: <20040321131109.GA28413@gondor.apana.org.au> (raw)
[-- Attachment #1: Type: text/plain, Size: 336 bytes --]
Hi:
This patch fixes the sysfs store functions for pmdisk when the input
contains a trailing newline.
Cheers,
--
Debian GNU/Linux 3.0 is out! ( http://www.debian.org/ )
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
[-- Attachment #2: p --]
[-- Type: text/plain, Size: 1389 bytes --]
Index: kernel-2.5/kernel/power/disk.c
===================================================================
RCS file: /home/gondolin/herbert/src/CVS/debian/kernel-source-2.5/kernel/power/disk.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 disk.c
--- a/kernel-2.5/kernel/power/disk.c 11 Mar 2004 02:55:21 -0000 1.1.1.3
+++ b/kernel-2.5/kernel/power/disk.c 21 Mar 2004 13:00:40 -0000
@@ -285,11 +285,16 @@
{
int error = 0;
int i;
+ int len;
+ char * p;
u32 mode = 0;
+ p = memchr(buf, '\n', n);
+ len = p ? p - buf: n;
+
down(&pm_sem);
for (i = PM_DISK_FIRMWARE; i < PM_DISK_MAX; i++) {
- if (!strcmp(buf,pm_disk_modes[i])) {
+ if (!strncmp(buf,pm_disk_modes[i],len)) {
mode = i;
break;
}
Index: kernel-2.5/kernel/power/main.c
===================================================================
RCS file: /home/gondolin/herbert/src/CVS/debian/kernel-source-2.5/kernel/power/main.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 main.c
--- a/kernel-2.5/kernel/power/main.c 28 Sep 2003 04:44:22 -0000 1.1.1.2
+++ b/kernel-2.5/kernel/power/main.c 21 Mar 2004 12:59:48 -0000
@@ -218,10 +218,15 @@
{
u32 state = PM_SUSPEND_STANDBY;
char ** s;
+ char * p;
int error;
+ int len;
+
+ p = memchr(buf, '\n', n);
+ len = p ? p - buf: n;
for (s = &pm_states[state]; *s; s++, state++) {
- if (!strcmp(buf,*s))
+ if (!strncmp(buf,*s,len))
break;
}
if (*s)
reply other threads:[~2004-03-21 13:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040321131109.GA28413@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mochel@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).