Lines 1-6
Link Here
|
1 |
$OpenBSD: patch-file_c,v 1.2 2002/11/13 17:15:49 naddy Exp $ |
1 |
--- file.c.orig Mon May 31 04:34:15 2004 |
2 |
--- file.c.orig Sun Jun 16 02:56:44 2002 |
2 |
+++ file.c Mon Nov 1 20:58:16 2004 |
3 |
+++ file.c Mon Nov 11 06:54:23 2002 |
|
|
4 |
@@ -18,6 +18,7 @@ |
3 |
@@ -18,6 +18,7 @@ |
5 |
*/ |
4 |
*/ |
6 |
|
5 |
|
Lines 9-49
Link Here
|
9 |
#include "mpage.h" |
8 |
#include "mpage.h" |
10 |
|
9 |
|
11 |
|
10 |
|
12 |
@@ -101,10 +102,10 @@ do_pr_file(fname, asheet, outfd) |
11 |
@@ -119,11 +120,11 @@ |
13 |
* header or not |
|
|
14 |
*/ |
12 |
*/ |
|
|
13 |
#define DASHES "-- " |
15 |
if (opt_header != NULL) |
14 |
if (opt_header != NULL) |
16 |
- (void)sprintf(command, "%s -l%d -w%d -h \"%s\" %s", prprog, |
15 |
- (void)sprintf(command, "%s -l%d -w%d -h \"%s\" %s%s", prprog, |
17 |
+ (void)snprintf(command, sizeof(command), "%s -l%d -w%d -h \"%s\" %s", prprog, |
16 |
+ (void)snprintf(command, sizeof(command), "%s -l%d -w%d -h \"%s\" %s%s", prprog, |
18 |
asheet->sh_plength, asheet->sh_cwidth, opt_header, fname); |
17 |
asheet->sh_plength, asheet->sh_cwidth, opt_header, |
|
|
18 |
fname[0] == '-' ? DASHES : "", fname); |
19 |
else |
19 |
else |
20 |
- (void)sprintf(command, "%s -l%d -w%d %s", prprog, |
20 |
- (void)sprintf(command, "%s -l%d -w%d %s%s", prprog, |
21 |
+ (void)snprintf(command, sizeof(command), "%s -l%d -w%d %s", prprog, |
21 |
+ (void)snprintf(command, sizeof(command), "%s -l%d -w%d %s%s", prprog, |
22 |
asheet->sh_plength, asheet->sh_cwidth, fname); |
22 |
asheet->sh_plength, asheet->sh_cwidth, |
|
|
23 |
fname[0] == '-' ? DASHES : "", fname); |
23 |
/* |
24 |
/* |
24 |
* open a pipe to the proper pr(1) command, and pr provides |
25 |
@@ -168,7 +169,7 @@ |
25 |
@@ -148,7 +149,7 @@ do_stdin(asheet, outfd) |
26 |
* but the tmpfilename |
26 |
* a temporary file; this temporary file will then |
27 |
*/ |
27 |
* be used as input to the do_doc routine |
28 |
|
28 |
*/ |
29 |
- (void) strcpy(tmpfile, "/usr/tmp/mpage-stdin-XXXXXX"); |
29 |
- (void)strcpy(tmpfile, "/usr/tmp/mpageXXXXXX"); |
30 |
+ (void) strlcpy(tmpfile, "/tmp/mpage-stdin-XXXXXX", sizeof(tmpfile)); |
30 |
+ (void)strlcpy(tmpfile, "/tmp/mpageXXXXXX", sizeof(tmpfile)); |
31 |
if ( (tmpfd = mkstemp(tmpfile)) == -1) { |
31 |
if ( (tmpfd = mkstemp(tmpfile)) == -1) { |
32 |
fprintf(stderr, "%s: cannot create temporary file", MPAGE); |
32 |
fprintf(stderr, "%s: cannot create temporary file", MPAGE); |
33 |
perror(MPAGE); |
33 |
perror(MPAGE); |
34 |
@@ -217,11 +218,11 @@ |
34 |
@@ -156,11 +157,13 @@ do_stdin(asheet, outfd) |
|
|
35 |
} |
35 |
} |
36 |
close(tmpfd); |
36 |
close(tmpfd); |
37 |
if (opt_header != NULL) |
37 |
if (opt_header != NULL) |
38 |
- (void)sprintf(command, "%s -l%d -w%d -h \"%s\"> %s", prprog, |
38 |
- (void)sprintf(command, "%s -l%d -w%d -h \"%s\" > %s", prprog, |
39 |
+ (void)snprintf(command, sizeof(command), |
39 |
+ (void)snprintf(command, sizeof(command), "%s -l%d -w%d -h \"%s\" > %s", prprog, |
40 |
+ "%s -l%d -w%d -h \"%s\"> %s", prprog, |
|
|
41 |
asheet->sh_plength, asheet->sh_cwidth, |
40 |
asheet->sh_plength, asheet->sh_cwidth, |
42 |
opt_header, tmpfile); |
41 |
opt_header, tmpfile); |
43 |
else |
42 |
else |
44 |
- (void)sprintf(command, "%s -l%d -w%d > %s", prprog, |
43 |
- (void)sprintf(command, "%s -l%d -w%d > %s", prprog, |
45 |
+ (void)snprintf(command, sizeof(command), |
44 |
+ (void)snprintf(command, sizeof(command), "%s -l%d -w%d > %s", prprog, |
46 |
+ "%s -l%d -w%d > %s", prprog, |
|
|
47 |
asheet->sh_plength, asheet->sh_cwidth, tmpfile); |
45 |
asheet->sh_plength, asheet->sh_cwidth, tmpfile); |
48 |
/* |
46 |
/* |
49 |
* open a pipe to the pr(1) command which will create a |
47 |
* open a pipe to the pr(1) command which will create a |