From 27fcae78c29d538e690c745e4ca266c03e8e6e89 Mon Sep 17 00:00:00 2001
From: Fabian Keil <fk@fabiankeil.de>
Date: Sat, 5 Dec 2020 14:33:38 +0100
Subject: [PATCH] Fix compiler warning from GCC9 with -D_FORTIFY_SOURCE=2

   pcrs.c:284:14: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-overflow=]
     284 |       text = strncpy(text, replacement, length + 1);
         |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   pcrs.c: In function 'pcrs_compile':
   pcrs.c:268:13: note: length computed here
     268 |    length = strlen(replacement);
         |             ^~~~~~~~~~~~~~~~~~~

While the warning is correct, the length of the destination
argument also depends on the length of the source argument
so we're good.

Using strlcpy() instead of strncpy() suppresses the warning
and 'text' is filled with zeros anyway so the difference
doesn't matter.

Reported by Lee.
---
 pcrs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pcrs.c b/pcrs.c
index ca6ba680..83100983 100644
--- a/pcrs.c
+++ b/pcrs.c
@@ -281,7 +281,7 @@ static pcrs_substitute *pcrs_compile_replacement(const char *replacement, int tr
     */
    if (trivialflag)
    {
-      text = strncpy(text, replacement, length + 1);
+      strlcpy(text, replacement, length + 1);
       k = (int)length;
    }
 
-- 
2.49.0