[PMDISK] Fix strcmp in sysfs store
diff mbox series

Message ID 20040321131109.GA28413@gondor.apana.org.au
State New, archived
Headers show
Series
  • [PMDISK] Fix strcmp in sysfs store
Related show

Commit Message

Herbert Xu March 21, 2004, 1:11 p.m. UTC
Hi:

This patch fixes the sysfs store functions for pmdisk when the input
contains a trailing newline.

Cheers,

Patch
diff mbox series

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)