summaryrefslogtreecommitdiff
path: root/print/mpage/files/patch-file_c
blob: 725f8b09a8db1ef583290cb197d35a5dbbe3c8ef (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
36
37
38
39
40
41
42
43
44
45
46
47
--- file.c.orig	Mon May 31 04:34:15 2004
+++ file.c	Mon Nov  1 20:58:16 2004
@@ -18,6 +18,7 @@
  */
 
 
+#include <string.h>
 #include "mpage.h"
 
 
@@ -119,11 +120,11 @@
      */
 #define DASHES "-- "
     if (opt_header != NULL)
-        (void)sprintf(command, "%s -l%d -w%d -h \"%s\" %s%s", prprog,
+        (void)snprintf(command, sizeof(command), "%s -l%d -w%d -h \"%s\" %s%s", prprog,
                   asheet->sh_plength, asheet->sh_cwidth, opt_header,
                   fname[0] == '-' ? DASHES : "", fname);
     else
-        (void)sprintf(command, "%s -l%d -w%d %s%s", prprog,
+        (void)snprintf(command, sizeof(command), "%s -l%d -w%d %s%s", prprog,
                   asheet->sh_plength, asheet->sh_cwidth,
                   fname[0] == '-' ? DASHES : "", fname);
     /*
@@ -168,7 +169,7 @@
      * but the tmpfilename
      */
      
-    (void) strcpy(tmpfile, "/usr/tmp/mpage-stdin-XXXXXX");
+    (void) strlcpy(tmpfile, "/tmp/mpage-stdin-XXXXXX", sizeof(tmpfile));
     if ( (tmpfd = mkstemp(tmpfile)) == -1) {
         fprintf(stderr, "%s: cannot create temporary file", MPAGE);
         perror(MPAGE);
@@ -217,11 +218,11 @@
 	}
         close(tmpfd);
         if (opt_header != NULL)
-            (void)sprintf(command, "%s -l%d -w%d -h \"%s\" > %s", prprog,
+            (void)snprintf(command, sizeof(command), "%s -l%d -w%d -h \"%s\" > %s", prprog,
                       asheet->sh_plength, asheet->sh_cwidth,
                       opt_header, tmpfile);
         else
-            (void)sprintf(command, "%s -l%d -w%d > %s", prprog,
+            (void)snprintf(command, sizeof(command), "%s -l%d -w%d > %s", prprog,
                       asheet->sh_plength, asheet->sh_cwidth, tmpfile);
         /*
          * open a pipe to the pr(1) command which will create a