Index | Thread | Search

From:
Han Boetes <hboetes@gmail.com>
Subject:
replace 2 last instances of strncpy with strlcpy
To:
tech@openbsd.org
Cc:
Omar Polo <op@omarpolo.com>
Date:
Mon, 23 Feb 2026 19:35:31 +0100

Download raw body.

Thread
  • Han Boetes:

    replace 2 last instances of strncpy with strlcpy

I would also like to propose this minor diff.

BR
Han

diff --git a/extend.c b/extend.c
index 154ff30..1048c0b 100644
--- a/extend.c
+++ b/extend.c
@@ -600,10 +600,8 @@ evalbuffer(int f, int n)
          llen = llength(lp);
          if (llen >= BUFSIZE)
              return (FALSE);
-        (void)strncpy(excbuf, ltext(lp), llen);
+        (void)strlcpy(excbuf, ltext(lp), llen + 1);

-        /* make sure the line is terminated */
-        excbuf[llen] = '\0';
          if ((s = excline(excbuf, llen, lnum)) != TRUE) {
              cleanup();
              return (s);
diff --git a/tags.c b/tags.c
index c470acf..b1d623a 100644
--- a/tags.c
+++ b/tags.c
@@ -473,8 +473,7 @@ curtoken(int f, int n, char *token)
          r = FALSE;
          goto cleanup;
      }
-    strncpy(token, ltext(curwp->w_dotp) + tdoto, size);
-    token[size] = '\0';
+    strlcpy(token, ltext(curwp->w_dotp) + tdoto, size + 1);
      r = TRUE;

  cleanup: