[PMDISK] Fix strcmp in sysfs store

From: Herbert Xu
Date: Sun Mar 21 2004 - 08:14:20 EST


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@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
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)