[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.2.00.1102112227040.16994@swampdragon.chaosbits.net>
Date: Fri, 11 Feb 2011 22:30:59 +0100 (CET)
From: Jesper Juhl <jj@...osbits.net>
To: linux-kernel@...r.kernel.org
cc: linux-raid@...r.kernel.org, Neil Brown <neilb@...e.de>,
Neil Brown <neilb@....unsw.edu.au>
Subject: [PATCH] md: Remove risk of overflow via sprintf) by using snprintf()
in md_check_recovery()
sprintf() is dangerous - given the wrong source string it will overflow
the destination. snprintf() is safer in that at least we'll never overflow
the destination. Even if overflow will never happen today, code changes
over time and snprintf() is just safer in the long run.
Signed-off-by: Jesper Juhl <jj@...osbits.net>
---
md.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
just compile tested
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 0cc30ec..6283658 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7164,7 +7164,7 @@ void md_check_recovery(mddev_t *mddev)
if (mddev->pers->hot_remove_disk(
mddev, rdev->raid_disk)==0) {
char nm[20];
- sprintf(nm,"rd%d", rdev->raid_disk);
+ snprintf(nm, sizeof(nm), "rd%d", rdev->raid_disk);
sysfs_remove_link(&mddev->kobj, nm);
rdev->raid_disk = -1;
}
--
Jesper Juhl <jj@...osbits.net> http://www.chaosbits.net/
Plain text mails only, please.
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists