Print this page
10127 coreadm is mis-using strcpy()

@@ -19,10 +19,11 @@
  * CDDL HEADER END
  */
 /*
  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ * Copyright (c) 2018, Joyent, Inc.
  */
 
 #include <stdio.h>
 #include <fcntl.h>
 #include <ctype.h>

@@ -545,19 +546,21 @@
                 if (n >= 1 && name[0] != '\0' &&
                     (n == 1 || len == strlen(buf))) {
                         if (n == 1)
                                 value[0] = '\0';
                         if (strcmp(name, "COREADM_GLOB_PATTERN") == 0) {
-                                (void) strcpy(gpattern, value);
+                                (void) strlcpy(gpattern, value,
+                                    sizeof (gpattern));
                                 continue;
                         }
                         if (strcmp(name, "COREADM_GLOB_CONTENT") == 0) {
                                 (void) proc_str2content(value, &glob_content);
                                 continue;
                         }
                         if (strcmp(name, "COREADM_INIT_PATTERN") == 0) {
-                                (void) strcpy(ipattern, value);
+                                (void) strlcpy(ipattern, value,
+                                    sizeof (ipattern));
                                 continue;
                         }
                         if (strcmp(name, "COREADM_INIT_CONTENT") == 0) {
                                 (void) proc_str2content(value, &init_content);
                                 continue;