]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
blockdev: use snprintf() rather than sprintf()
authorKarel Zak <kzak@redhat.com>
Tue, 27 Jul 2021 10:51:43 +0000 (12:51 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 29 Jul 2021 09:57:17 +0000 (11:57 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/blockdev.c

index 3c5be173a185c67ad8482b868e20953dcb02943f..c16cb10954cb4229a4db8848cf15402d8a00d217 100644 (file)
@@ -442,7 +442,7 @@ static void report_all_devices(void)
                           &ma, &mi, &sz, ptname) != 4)
                        continue;
 
-               sprintf(device, "/dev/%s", ptname);
+               snprintf(device, sizeof(device), "/dev/%s", ptname);
                report_device(device, 1);
        }
 
@@ -479,12 +479,12 @@ static void report_device(char *device, int quiet)
 
                        if (ul_path_read_u64(pc, &start, "start") != 0)
                                /* TRANSLATORS: Start sector not available. Max. 15 letters. */
-                               sprintf(start_str, "%15s", _("N/A"));
+                               snprintf(start_str, sizeof(start_str), "%15s", _("N/A"));
                }
                ul_unref_path(pc);
        }
        if (!*start_str)
-               sprintf(start_str, "%15ju", start);
+               snprintf(start_str, sizeof(start_str), "%15ju", start);
 
        if (ioctl(fd, BLKROGET, &ro) == 0 &&
            ioctl(fd, BLKRAGET, &ra) == 0 &&