[PATCH] clean up missing overflow check in get_blkdev_list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Patch to clean up missing overflow check in get_blkdev_list.  the printf which
adds the "Block Devices" string in /proc/devices can overflow the presented page
if get_chrdev_list eats up the entire 4k space. Tested by myself, with good
results.

Signed-off-by: Neil Horman <[email protected]>

 genhd.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)



--- linux-2.6/drivers/block/genhd.c.orig	2005-08-16 10:12:02.000000000 -0400
+++ linux-2.6/drivers/block/genhd.c	2005-08-16 10:12:27.000000000 -0400
@@ -45,7 +45,7 @@ int get_blkdev_list(char *p, int used)
 	struct blk_major_name *n;
 	int i, len;
 
-	len = sprintf(p, "\nBlock devices:\n");
+	len = snprintf(p, (PAGE_SIZE-used), "\nBlock devices:\n");
 
 	down(&block_subsys_sem);
 	for (i = 0; i < ARRAY_SIZE(major_names); i++) {
-- 
/***************************************************
 *Neil Horman
 *Software Engineer
 *Red Hat, Inc.
 *[email protected]
 *gpg keyid: 1024D / 0x92A74FA1
 *http://pgp.mit.edu
 ***************************************************/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux