diff options
author | Tejun Heo <htejun@gmail.com> | 2007-01-02 06:19:40 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-09 17:39:30 -0500 |
commit | 8bfa79fcb81d2bdb043f60ab4171704467808b55 (patch) | |
tree | 8b81b15237110ee30626057541e07b0ba8aa80bc /drivers/ata/pata_hpt37x.c | |
parent | a0cf733b333eeeafb7324e2897448006c693c26c (diff) |
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 <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/pata_hpt37x.c')
-rw-r--r-- | drivers/ata/pata_hpt37x.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c index ff767755e98b..9e1eb473c0a1 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c | |||
@@ -349,23 +349,13 @@ static u32 hpt37x_find_mode(struct ata_port *ap, int speed) | |||
349 | 349 | ||
350 | static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, const char *list[]) | 350 | static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, const char *list[]) |
351 | { | 351 | { |
352 | unsigned char model_num[ATA_ID_PROD_LEN]; | 352 | unsigned char model_num[ATA_ID_PROD_LEN + 1]; |
353 | char *s; | ||
354 | unsigned int len; | ||
355 | int i = 0; | 353 | int i = 0; |
356 | 354 | ||
357 | ata_id_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num)); | 355 | ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num)); |
358 | s = &model_num[0]; | ||
359 | len = strnlen(s, sizeof(model_num)); | ||
360 | 356 | ||
361 | /* ATAPI specifies that empty space is blank-filled; remove blanks */ | 357 | while (list[i] != NULL) { |
362 | while ((len > 0) && (s[len - 1] == ' ')) { | 358 | if (!strcmp(list[i], model_num)) { |
363 | len--; | ||
364 | s[len] = 0; | ||
365 | } | ||
366 | |||
367 | while(list[i] != NULL) { | ||
368 | if (!strncmp(list[i], s, len)) { | ||
369 | printk(KERN_WARNING DRV_NAME ": %s is not supported for %s.\n", | 359 | printk(KERN_WARNING DRV_NAME ": %s is not supported for %s.\n", |
370 | modestr, list[i]); | 360 | modestr, list[i]); |
371 | return 1; | 361 | return 1; |