From 8bfa79fcb81d2bdb043f60ab4171704467808b55 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 2 Jan 2007 20:19:40 +0900 Subject: libata: use ata_id_c_string() There were several places where ATA ID strings are manually terminated and in some places possibly unterminated strings were passed to string functions which don't limit length like strstr(). This patch converts all of them over to ata_id_c_string(). Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/pata_it821x.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'drivers/ata/pata_it821x.c') diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c index c84dfaede89..171fbd206bd 100644 --- a/drivers/ata/pata_it821x.c +++ b/drivers/ata/pata_it821x.c @@ -531,22 +531,9 @@ static int it821x_smart_set_mode(struct ata_port *ap, struct ata_device **unused static void it821x_dev_config(struct ata_port *ap, struct ata_device *adev) { - unsigned char model_num[ATA_ID_PROD_LEN]; - char *s; - unsigned int len; + unsigned char model_num[ATA_ID_PROD_LEN + 1]; - /* This block ought to be a library routine as it is in several - drivers now */ - - ata_id_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num)); - s = &model_num[0]; - len = strnlen(s, sizeof(model_num)); - - /* ATAPI specifies that empty space is blank-filled; remove blanks */ - while ((len > 0) && (s[len - 1] == ' ')) { - len--; - s[len] = 0; - } + ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num)); if (adev->max_sectors > 255) adev->max_sectors = 255; -- cgit v1.2.3