patch-2.4.25 linux-2.4.25/arch/ppc64/kernel/mf_proc.c

Next file: linux-2.4.25/arch/ppc64/kernel/misc.S
Previous file: linux-2.4.25/arch/ppc64/kernel/lparcfg.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.24/arch/ppc64/kernel/mf_proc.c linux-2.4.25/arch/ppc64/kernel/mf_proc.c
@@ -220,19 +220,22 @@
 
 int proc_mf_change_side(struct file *file, const char *buffer, unsigned long count, void *data)
 {
+	char side;
+
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
+	if (count == 0)
+		return 0;
+	if (get_user(side, buffer))
+		return -EFAULT;
 
-	if ((*buffer != 'A') &&
-	    (*buffer != 'B') &&
-	    (*buffer != 'C') &&
-	    (*buffer != 'D'))
+	if ((side != 'A') && (side != 'B') && (side != 'C') && (side != 'D'))
 	{
 		printk(KERN_ERR "mf_proc.c: proc_mf_change_side: invalid side\n");
 		return -EINVAL;
 	}
 
-	mf_setSide(*buffer);
+	mf_setSide(side);
 
 	return count;			
 }
@@ -256,20 +259,24 @@
 
 int proc_mf_change_src(struct file *file, const char *buffer, unsigned long count, void *data)
 {
+	char stkbuf[10];
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 
-	if ((count < 4) && (count != 1))
-	{
+	if ((count < 4) && (count != 1)) {
 		printk(KERN_ERR "mf_proc: invalid src\n");
 		return -EINVAL;
 	}
 
-	if ((count == 1) && ((*buffer) == '\0'))
-	{
+	if (count > 9)
+		count = 9;
+	if (copy_from_user (stkbuf, buffer, count))
+		return -EFAULT;
+
+	if ((count == 1) && ((*stkbuf) == '\0')) {
 		mf_clearSrc();
 	} else {
-		mf_displaySrc(*(u32 *)buffer);
+		mf_displaySrc(*(u32 *)stkbuf);
 	}
 
 	return count;			

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)