summaryrefslogtreecommitdiffstats
path: root/patches/libfaketime-0.9.7/0002-faketime-fix-format-truncation-warning.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/libfaketime-0.9.7/0002-faketime-fix-format-truncation-warning.patch')
-rw-r--r--patches/libfaketime-0.9.7/0002-faketime-fix-format-truncation-warning.patch41
1 files changed, 41 insertions, 0 deletions
diff --git a/patches/libfaketime-0.9.7/0002-faketime-fix-format-truncation-warning.patch b/patches/libfaketime-0.9.7/0002-faketime-fix-format-truncation-warning.patch
new file mode 100644
index 000000000..830c810f6
--- /dev/null
+++ b/patches/libfaketime-0.9.7/0002-faketime-fix-format-truncation-warning.patch
@@ -0,0 +1,41 @@
+From: Juergen Borleis <jbe@pengutronix.de>
+Date: Thu, 23 May 2019 11:30:23 +0200
+Subject: [PATCH] faketime: fix format truncation warning.
+
+GCC8 states:
+
+ faketime.c:289:45: error: '%s' directive output may be truncated writing
+ up to 4095 bytes into a region of size between 0 and 4095
+ [-Werror=format-truncation=]
+
+Using snprintf() is a good idea to not write behind the end of an array,
+but a truncation of the content is an ugly failure as well.
+
+Since both input buffers are 4096 bytes in size, the output buffer must be
+at least twice in size.
+---
+ src/faketime.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/faketime.c b/src/faketime.c
+index 138ebbd55388..647c0f0c318c 100644
+--- a/src/faketime.c
++++ b/src/faketime.c
+@@ -209,7 +209,7 @@ int main (int argc, char **argv)
+ int shm_fd;
+ sem_t *sem;
+ struct ft_shared_s *ft_shared;
+- char shared_objs[PATH_BUFSIZE];
++ char shared_objs[PATH_BUFSIZE * 2];
+
+ /*
+ * Casting of getpid() return value to long needed to make GCC on SmartOS
+@@ -286,7 +286,7 @@ int main (int argc, char **argv)
+ exit(EXIT_FAILURE);
+ }
+
+- snprintf(shared_objs, PATH_BUFSIZE, "%s %s", sem_name, shm_name);
++ snprintf(shared_objs, sizeof(shared_objs), "%s %s", sem_name, shm_name);
+ setenv("FAKETIME_SHARED", shared_objs, true);
+ sem_close(sem);
+ }