aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-core.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-01-02 06:19:40 -0500
committerJeff Garzik <jeff@garzik.org>2007-02-09 17:39:30 -0500
commit8bfa79fcb81d2bdb043f60ab4171704467808b55 (patch)
tree8b81b15237110ee30626057541e07b0ba8aa80bc /drivers/ata/libata-core.c
parenta0cf733b333eeeafb7324e2897448006c693c26c (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/libata-core.c')
-rw-r--r--drivers/ata/libata-core.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 7d4b002568e7..a03019c40ac4 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3325,35 +3325,20 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
3325 { } 3325 { }
3326}; 3326};
3327 3327
3328static int ata_strim(char *s, size_t len)
3329{
3330 len = strnlen(s, len);
3331
3332 /* ATAPI specifies that empty space is blank-filled; remove blanks */
3333 while ((len > 0) && (s[len - 1] == ' ')) {
3334 len--;
3335 s[len] = 0;
3336 }
3337 return len;
3338}
3339
3340unsigned long ata_device_blacklisted(const struct ata_device *dev) 3328unsigned long ata_device_blacklisted(const struct ata_device *dev)
3341{ 3329{
3342 unsigned char model_num[ATA_ID_PROD_LEN]; 3330 unsigned char model_num[ATA_ID_PROD_LEN + 1];
3343 unsigned char model_rev[ATA_ID_FW_REV_LEN]; 3331 unsigned char model_rev[ATA_ID_FW_REV_LEN + 1];
3344 unsigned int nlen, rlen;
3345 const struct ata_blacklist_entry *ad = ata_device_blacklist; 3332 const struct ata_blacklist_entry *ad = ata_device_blacklist;
3346 3333
3347 ata_id_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num)); 3334 ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
3348 ata_id_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev)); 3335 ata_id_c_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev));
3349 nlen = ata_strim(model_num, sizeof(model_num));
3350 rlen = ata_strim(model_rev, sizeof(model_rev));
3351 3336
3352 while (ad->model_num) { 3337 while (ad->model_num) {
3353 if (!strncmp(ad->model_num, model_num, nlen)) { 3338 if (!strcmp(ad->model_num, model_num)) {
3354 if (ad->model_rev == NULL) 3339 if (ad->model_rev == NULL)
3355 return ad->horkage; 3340 return ad->horkage;
3356 if (!strncmp(ad->model_rev, model_rev, rlen)) 3341 if (!strcmp(ad->model_rev, model_rev))
3357 return ad->horkage; 3342 return ad->horkage;
3358 } 3343 }
3359 ad++; 3344 ad++;