summaryrefslogtreecommitdiffstats
path: root/debian/patches/upstream/findmnt-always-zero-terminate-SOURCES-data.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/upstream/findmnt-always-zero-terminate-SOURCES-data.patch')
-rw-r--r--debian/patches/upstream/findmnt-always-zero-terminate-SOURCES-data.patch46
1 files changed, 46 insertions, 0 deletions
diff --git a/debian/patches/upstream/findmnt-always-zero-terminate-SOURCES-data.patch b/debian/patches/upstream/findmnt-always-zero-terminate-SOURCES-data.patch
new file mode 100644
index 0000000..b173277
--- /dev/null
+++ b/debian/patches/upstream/findmnt-always-zero-terminate-SOURCES-data.patch
@@ -0,0 +1,46 @@
+From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= <thomas@t-8ch.de>
+Date: Sun, 21 Apr 2024 20:00:31 +0200
+Subject: findmnt: always zero-terminate SOURCES data
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+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>
+(cherry picked from commit 6594679e9af805075c282da35b1b2a8d767e403b)
+---
+ misc-utils/findmnt.c | 5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
+index 2e4d59e..f40b137 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);