libsmartcols expects it's data fields to be zero terminated.
See the call to strlen() in scols_column_greatest_wrap().
ul_buffer however does not guarantee that termination,
ul_buffer_append_strings() discard the zero-termination.
Always zero-terminate in get_data_col_sources() and drop the now
unnecessary variable "i".
Closes: https://github.com/util-linux/util-linux/issues/2980
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
static char *get_data_col_sources(struct libmnt_fs *fs, int evaluate, size_t *datasiz)
{
const char *tag = NULL, *p = NULL;
- int i = 0;
const char *device = NULL;
char *val = NULL;
blkid_dev_iterate iter;
dev = blkid_verify(blk_cache, dev);
if (!dev)
continue;
- if (i != 0)
- ul_buffer_append_data(&buf, "\0", 1);
ul_buffer_append_string(&buf, blkid_dev_devname(dev));
- i++;
+ ul_buffer_append_data(&buf, "\0", 1);
}
blkid_dev_iterate_end(iter);
free(val);