From a71d565138b5100ebfbac99293bc467d0fc21ef6 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 10 Apr 2021 15:26:24 +0900 Subject: [PATCH] Revert "xcursor: use strncat instead of strncpy" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 7dffe9339bf8a92a556098d86712c4c38ac95226, which introduced another linter error with -O3: error: ‘strncat’ specified bound 7 equals source length [-Werror=stringop-overflow=] This makes sense because strncat(dest, "cursors", strlen("cursors")) is moot in security point of view. The next commit will replace strncpy() with memcpy(), so let's restore the original implementation. --- xcursor/xcursor.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xcursor/xcursor.c b/xcursor/xcursor.c index acb2e1a8..d33dee28 100644 --- a/xcursor/xcursor.c +++ b/xcursor/xcursor.c @@ -655,7 +655,11 @@ _XcursorAddPathElt (char *path, const char *elt, int len) elt++; len--; } - strncat (path + pathlen, elt, len); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" + strncpy (path + pathlen, elt, len); + path[pathlen + len] = '\0'; +#pragma GCC diagnostic pop } static char *