summaryrefslogtreecommitdiffstats
path: root/disk-utils/fdisk-list.c
diff options
context:
space:
mode:
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;
}
-