summaryrefslogtreecommitdiff
path: root/print/mpage/files/patch-args.c
blob: 81695b62a83039049ecc6d77ce03cb73faa354b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
$OpenBSD: patch-args_c,v 1.3 2002/11/13 17:15:49 naddy Exp $
--- args.c.orig	Thu Oct 17 07:22:48 2002
+++ args.c	Mon Nov 11 05:43:01 2002
@@ -35,6 +35,7 @@ do_args(int argc, char **argv, int envfl
     int consumed;
     int currarg;
     int opterrors;
+    size_t len;
 
     int i;
 
@@ -142,18 +143,17 @@ do_args(int argc, char **argv, int envfl
                         break;
                 case 'C':    /* select character definitions */
                         consumed = 1;
+                        len = (strlen(libdir) + strlen(optstr) + 2);
                         if (*++optstr) { /* did we get a encoding name ? */
-                            if ((charvec_file = (char *) malloc(strlen(libdir) +
-                                                                strlen(optstr) +
-                                                                2)) == NULL) {
+                            if ((charvec_file = (char *) malloc(len)) == NULL) {
                                 perror(optstr);
                                 fprintf(stderr,
                                     "ignoring character encoding definition\n");
                             }
                             else {
-                                (void) strcpy(charvec_file, libdir);
-                                (void) strcat(charvec_file, "/");
-                                (void) strcat(charvec_file, optstr);
+                                (void) strlcpy(charvec_file, libdir, len);
+                                (void) strlcat(charvec_file, "/", len);
+                                (void) strlcat(charvec_file, optstr, len);
                                 opt_encoding = 1;
                             }
                         }