Print this page
10128 csplit should use strlcpy

@@ -25,10 +25,14 @@
 
 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
 /*        All Rights Reserved   */
 
 /*
+ * Copyright (c) 2018, Joyent, Inc.
+ */
+
+/*
  * csplit - Context or line file splitter
  * Compile: cc -O -s -o csplit csplit.c
  */
 
 #include <stdio.h>

@@ -389,11 +393,11 @@
                         }
                         *delim = savedelim;
                 }
 
                 if ((opfil = fopen(file, "w")) == NULL) {
-                        (void) strcpy(tfile, file);
+                        (void) strlcpy(tfile, file, sizeof (tfile));
                         (void) sprintf(fptr, "%.*d", fiwidth, (ctr-2));
                         fatal("Cannot create %s\n", tfile);
                 }
                 return (opfil);
         }