mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Neil Horman <nhorman@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org, torvalds@osdl.org
Subject: [PATCH] clean up missing overflow check in get_blkdev_list
Date: Tue, 16 Aug 2005 14:48:13 -0400	[thread overview]
Message-ID: <20050816184813.GH16120@hmsendeavour.rdu.redhat.com> (raw)

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 <nhorman@redhat.com>

 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.
 *nhorman@redhat.com
 *gpg keyid: 1024D / 0x92A74FA1
 *http://pgp.mit.edu
 ***************************************************/

             reply	other threads:[~2005-08-16 18:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-16 18:48 Neil Horman [this message]
2005-08-16 19:38 ` Christoph Hellwig

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=20050816184813.GH16120@hmsendeavour.rdu.redhat.com \
    --to=nhorman@redhat.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@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

all inboxes | Powered by JetHome®