File inotifywait-nullterminate.patch of Package inotify-tools.40686
From c6956e832d27d9aedf9dfefc9e79f19f82c5bdd6 Mon Sep 17 00:00:00 2001
From: auouymous <au@qzx.com>
Date: Fri, 14 Jan 2022 00:07:50 -0700
Subject: [PATCH] Properly terminate escaped CSV strings.
strncpy() does not append a '\0' to the destination string. This results
in the contents of a previous longer string showing at the end of a
shorter string, or garbage if the buffer was not zeroed by the operating
system.
---
src/inotifywait.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/inotifywait.c b/src/inotifywait.c
index 978d4d0b..31dd63d8 100644
--- a/src/inotifywait.c
+++ b/src/inotifywait.c
@@ -73,6 +73,7 @@ static char* csv_escape_len(const char* string, size_t len) {
!strchr(string, '\n') && string[0] != ' ' &&
string[len - 1] != ' ') {
strncpy(csv, string, len);
+ csv[len] = '\0';
return csv;
}