From: Joe Carnuccio Date: Wed, 30 Oct 2013 07:38:19 +0000 (-0400) Subject: [SCSI] qla2xxx: Fix undefined behavior in call to snprintf(). X-Git-Tag: next-20131220~13^2~45 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=d449a833f9cb691e7b2a5ffd2c43b620ce5df53e;p=karo-tx-linux.git [SCSI] qla2xxx: Fix undefined behavior in call to snprintf(). Signed-off-by: Joe Carnuccio Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 3464782ab5a4..2a14df86f639 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -917,8 +917,8 @@ qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr, return snprintf(buf, PAGE_SIZE, "%s\n", vha->hw->mr.serial_num); } else if (IS_FWI2_CAPABLE(ha)) { - qla2xxx_get_vpd_field(vha, "SN", buf, PAGE_SIZE); - return snprintf(buf, PAGE_SIZE, "%s\n", buf); + qla2xxx_get_vpd_field(vha, "SN", buf, PAGE_SIZE - 1); + return strlen(strcat(buf, "\n")); } sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1;