Skip to content

Commit

Permalink
panasonic-laptop: use snprintf with PAGE_SIZE in sysfs attributes
Browse files Browse the repository at this point in the history
Instead of just sprintf() into the page-sized buffer provided
by the sysfs/device_attribute API, we use snprintf with PAGE_SIZE
as an additional safeguard.

Signed-off-by: Martin Lucina <mato@kotelna.sk>
Signed-off-by: Harald Welte <laforge@gnumonks.org>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Harald Welte authored and Len Brown committed Apr 4, 2009
1 parent c542aad commit ba256b4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/platform/x86/panasonic-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static ssize_t show_numbatt(struct device *dev, struct device_attribute *attr,
if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf))
return -EIO;

return sprintf(buf, "%u\n", pcc->sinf[SINF_NUM_BATTERIES]);
return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_NUM_BATTERIES]);
}

static ssize_t show_lcdtype(struct device *dev, struct device_attribute *attr,
Expand All @@ -379,7 +379,7 @@ static ssize_t show_lcdtype(struct device *dev, struct device_attribute *attr,
if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf))
return -EIO;

return sprintf(buf, "%u\n", pcc->sinf[SINF_LCD_TYPE]);
return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_LCD_TYPE]);
}

static ssize_t show_mute(struct device *dev, struct device_attribute *attr,
Expand All @@ -391,7 +391,7 @@ static ssize_t show_mute(struct device *dev, struct device_attribute *attr,
if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf))
return -EIO;

return sprintf(buf, "%u\n", pcc->sinf[SINF_MUTE]);
return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_MUTE]);
}

static ssize_t show_sticky(struct device *dev, struct device_attribute *attr,
Expand All @@ -403,7 +403,7 @@ static ssize_t show_sticky(struct device *dev, struct device_attribute *attr,
if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf))
return -EIO;

return sprintf(buf, "%u\n", pcc->sinf[SINF_STICKY_KEY]);
return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_STICKY_KEY]);
}

static ssize_t set_sticky(struct device *dev, struct device_attribute *attr,
Expand Down

0 comments on commit ba256b4

Please sign in to comment.