diff options
author | Thomas Weißschuh <thomas@t-8ch.de> | 2024-04-21 20:00:31 +0200 |
---|---|---|
committer | Thomas Weißschuh <thomas@t-8ch.de> | 2024-04-21 20:00:31 +0200 |
commit | 6594679e9af805075c282da35b1b2a8d767e403b (patch) | |
tree | 047615d6737b44556bfbcc4958ca10ed9447d00e | |
parent | a6d12b403eec9f3fddc0fa82325dac04826c4b48 (diff) | |
download | util-linux-6594679e9af805075c282da35b1b2a8d767e403b.tar.gz |
findmnt: always zero-terminate SOURCES data
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>
-rw-r--r-- | misc-utils/findmnt.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index 2e4d59ecc0..f40b13726a 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -552,7 +552,6 @@ static char *get_vfs_attr(struct libmnt_fs *fs, int sizetype) 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; @@ -602,10 +601,8 @@ static char *get_data_col_sources(struct libmnt_fs *fs, int evaluate, size_t *da 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); |