diff options
| author | Heiko Carstens <hca@linux.ibm.com> | 2025-10-07 11:05:03 +0200 |
|---|---|---|
| committer | Heiko Carstens <hca@linux.ibm.com> | 2025-10-21 10:17:30 +0200 |
| commit | ffb5d3af5e2b52472f236f8bb13414c7fab99797 (patch) | |
| tree | 703b2a3db9793dfeebac82dd98217ee5251b5fd7 | |
| parent | ba06238bbe6a8697e281e2839fc54bcec45ae143 (diff) | |
s390/dcss: Use scnprintf() instead of sprintf()
Use scnprintf() instead of sprintf() for those cases where the destination
is an array and the size of the array is known at compile time.
This prevents theoretical buffer overflows, but also avoids that people
again and again spend time to figure out if the code is actually safe.
Reviewed-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
| -rw-r--r-- | drivers/s390/block/dcssblk.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 86fef4b15015..57d691ed0a63 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -674,8 +674,8 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char rc = dcssblk_assign_free_minor(dev_info); if (rc) goto release_gd; - sprintf(dev_info->gd->disk_name, "dcssblk%d", - dev_info->gd->first_minor); + scnprintf(dev_info->gd->disk_name, sizeof(dev_info->gd->disk_name), + "dcssblk%d", dev_info->gd->first_minor); list_add_tail(&dev_info->lh, &dcssblk_devices); if (!try_module_get(THIS_MODULE)) { |
