summaryrefslogtreecommitdiffstats
path: root/disk-utils/fdisk-list.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:32 +0000
commit8bb05ac73a5b448b339ce0bc8d396c82c459b47f (patch)
tree1fdda006866bca20d41cb206767ea5241e36852f /disk-utils/fdisk-list.c
parentAdding debian version 2.39.3-11. (diff)
downloadutil-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.tar.xz
util-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.zip
Merging upstream version 2.40.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'disk-utils/fdisk-list.c')
-rw-r--r--disk-utils/fdisk-list.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/disk-utils/fdisk-list.c b/disk-utils/fdisk-list.c
index f93ed10..26ae1bd 100644
--- a/disk-utils/fdisk-list.c
+++ b/disk-utils/fdisk-list.c
@@ -449,7 +449,7 @@ void list_available_columns(FILE *out)
termwidth = get_terminal_width(80);
- fprintf(out, USAGE_COLUMNS);
+ fputs(USAGE_COLUMNS, out);
while (fdisk_next_label(cxt, &lb) == 0) {
size_t width = 6; /* label name and separators */
@@ -479,21 +479,24 @@ void list_available_columns(FILE *out)
static int fieldname_to_id(const char *name, size_t namesz)
{
const struct fdisk_field *fl;
- char buf[namesz + 1];
+ char *buf;
assert(name);
assert(namesz);
assert(fields_label);
- memcpy(buf, name, namesz);
- buf[namesz] = '\0';
+ buf = strndup(name, namesz);
+ if (!buf)
+ return -1;
fl = fdisk_label_get_field_by_name(fields_label, buf);
if (!fl) {
warnx(_("%s unknown column: %s"),
fdisk_label_get_name(fields_label), buf);
+ free(buf);
return -1;
}
+ free(buf);
return fdisk_field_get_id(fl);
}
@@ -550,4 +553,3 @@ done:
*n = fields_nids;
return fields_ids;
}
-