From: Thomas Weißschuh Date: Sun, 21 Apr 2024 18:00:31 +0000 (+0200) Subject: findmnt: always zero-terminate SOURCES data X-Git-Tag: v2.42-start~392 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6594679e9af805075c282da35b1b2a8d767e403b;p=thirdparty%2Futil-linux.git 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 --- diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index 2e4d59ecc..f40b13726 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);