Remove all warnings. Change all strcpy -> strlcpy, strcat-> strlcat,
and sprintf -> snprintf.
This commit is contained in:
parent
e7c3778bc3
commit
14b1df39fb
@ -1,5 +1,27 @@
|
||||
--- file.c.orig Wed Nov 26 10:14:31 1997
|
||||
+++ file.c Mon Aug 16 20:40:45 1999
|
||||
+++ file.c Mon Dec 13 19:30:33 1999
|
||||
@@ -24,7 +24,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
-
|
||||
+#include <string.h>
|
||||
#include "mpage.h"
|
||||
|
||||
|
||||
@@ -108,10 +108,10 @@
|
||||
* header or not
|
||||
*/
|
||||
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, fname);
|
||||
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, fname);
|
||||
/*
|
||||
* open a pipe to the proper pr(1) command, and pr provides
|
||||
@@ -145,6 +145,7 @@
|
||||
char tmpfile[LINESIZE];
|
||||
char buffer[LINESIZE];
|
||||
@ -8,19 +30,27 @@
|
||||
|
||||
if (opt_pr) {
|
||||
Debug(DB_STDIN, "%%do_stdin: pr option selects text\n", 0);
|
||||
@@ -154,8 +155,10 @@
|
||||
@@ -154,14 +155,16 @@
|
||||
* a temporary file; this temporary file will then
|
||||
* be used as input to the do_doc routine
|
||||
*/
|
||||
- (void)strcpy(tmpfile, "/usr/tmp/mpageXXXXXX");
|
||||
- (void)mktemp(tmpfile);
|
||||
+ (void)strcpy(tmpfile, "/tmp/mpage.XXXXXX");
|
||||
+ (void)strlcpy(tmpfile, "/tmp/mpage.XXXXXX", sizeof(tmpfile));
|
||||
+
|
||||
+ fdd = mkstemp(tmpfile);
|
||||
+
|
||||
if (opt_header != NULL)
|
||||
(void)sprintf(command, "pr -l%d -w%d -h \"%s\"> %s",
|
||||
- (void)sprintf(command, "pr -l%d -w%d -h \"%s\"> %s",
|
||||
+ (void)snprintf(command, sizeof(command), "pr -l%d -w%d -h \"%s\"> %s",
|
||||
asheet->sh_plength, asheet->sh_cwidth,
|
||||
opt_header, tmpfile);
|
||||
else
|
||||
- (void)sprintf(command, "pr -l%d -w%d > %s",
|
||||
+ (void)snprintf(command, sizeof(command), "pr -l%d -w%d > %s",
|
||||
asheet->sh_plength, asheet->sh_cwidth, tmpfile);
|
||||
/*
|
||||
* open a pipe to the pr(1) command which will create a
|
||||
@@ -194,8 +197,11 @@
|
||||
* now open the temporary file and use do_doc to
|
||||
* convert it to PS
|
||||
|
56
print/mpage/patches/patch-argsc
Normal file
56
print/mpage/patches/patch-argsc
Normal file
@ -0,0 +1,56 @@
|
||||
--- args.c.orig Wed Nov 26 10:14:22 1997
|
||||
+++ args.c Mon Dec 13 19:32:26 1999
|
||||
@@ -45,6 +45,7 @@
|
||||
int consumed;
|
||||
int currarg;
|
||||
int opterrors;
|
||||
+ size_t len;
|
||||
|
||||
#define OPTARG() \
|
||||
{ consumed = 1; if(*++optstr == '\0') optstr = argv[++currarg]; }
|
||||
@@ -146,18 +147,17 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -341,10 +341,10 @@
|
||||
case 'P': /* Printer */
|
||||
consumed = 1;
|
||||
doprint = 1;
|
||||
- if (*++optstr)
|
||||
+ if (*++optstr) {
|
||||
if (!strcmp(optstr, "-"))
|
||||
doprint = 0; /* kill MPAGE envvar que setting*/
|
||||
- else {
|
||||
+ } else {
|
||||
printque = optstr;
|
||||
}
|
||||
break;
|
||||
@@ -429,7 +429,7 @@
|
||||
libdir = env;
|
||||
|
||||
if ((env = getenv("MPAGE")) != NULL) {
|
||||
- strcpy(copy, env);
|
||||
+ (void)strlcpy(copy, env, sizeof(copy));
|
||||
argv = slice(copy, &argc);
|
||||
if (do_args(argc, argv, 1) < 0) {
|
||||
fprintf(stderr, "%s: error in environment \"%s\"\n", MPAGE, env);
|
40
print/mpage/patches/patch-mpagec
Normal file
40
print/mpage/patches/patch-mpagec
Normal file
@ -0,0 +1,40 @@
|
||||
--- mpage.c.orig Wed Nov 26 10:14:47 1997
|
||||
+++ mpage.c Mon Dec 13 19:35:15 1999
|
||||
@@ -77,10 +77,10 @@
|
||||
*/
|
||||
if (doprint) {
|
||||
if (printque != NULL)
|
||||
- (void) sprintf(outcommand, "%s %s%s",
|
||||
+ (void) snprintf(outcommand, sizeof(outcommand), "%s %s%s",
|
||||
printprog, printarg, printque);
|
||||
else
|
||||
- (void) strcpy(outcommand, printprog);
|
||||
+ (void) strlcpy(outcommand, printprog, sizeof(outcommand));
|
||||
if ((outfd = popen(outcommand, "w")) == NULL) {
|
||||
fprintf(stderr, "%s: cannot create pipe for '%s'\n",
|
||||
MPAGE, outcommand);
|
||||
@@ -277,7 +277,7 @@
|
||||
exit(1);
|
||||
}
|
||||
while (fgets(buf, LINESIZE, charfp) != NULL) {
|
||||
- if (*buf != '%' && *buf != '\n')
|
||||
+ if (*buf != '%' && *buf != '\n') {
|
||||
if (first_encoding == -1) {
|
||||
first_encoding = atoi(buf);
|
||||
last_encoding = atoi(strchr(buf, ' '));
|
||||
@@ -286,11 +286,12 @@
|
||||
first_encoding, last_encoding);
|
||||
#endif
|
||||
}
|
||||
- else
|
||||
+ else {
|
||||
fprintf(outfd, "%s", buf);
|
||||
- }
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
- else { /* use internal default encoding */
|
||||
+ } else { /* use internal default encoding */
|
||||
int i;
|
||||
|
||||
first_encoding = encoding_table_first;
|
81
print/mpage/patches/patch-postc
Normal file
81
print/mpage/patches/patch-postc
Normal file
@ -0,0 +1,81 @@
|
||||
--- post.c.orig Wed Nov 26 10:20:43 1997
|
||||
+++ post.c Mon Dec 13 19:36:58 1999
|
||||
@@ -56,7 +56,7 @@
|
||||
/*
|
||||
* number of output lines on current logical page
|
||||
*/
|
||||
-static plcnt;
|
||||
+static int plcnt;
|
||||
|
||||
|
||||
int have_showsheet = 0;
|
||||
@@ -356,6 +356,8 @@
|
||||
FILE *outfd;
|
||||
{
|
||||
|
||||
+ size_t len;
|
||||
+
|
||||
Debug(DB_PSDOC, "%%ps_copyprolog: adding mpage prolog\n", 0);
|
||||
if (!have_showsheet) {
|
||||
fprintf(outfd, "/showsheet { showpage } bind def\n");
|
||||
@@ -396,15 +398,17 @@
|
||||
*/
|
||||
if (tex1)
|
||||
free(tex1);
|
||||
- tex1 = malloc(strlen(currline)+1);
|
||||
- strcpy(tex1, currline);
|
||||
+ len = (strlen(currline)+1);
|
||||
+ tex1 = malloc(len);
|
||||
+ (void)strlcpy(tex1, currline, len);
|
||||
fprintf(outfd, "%s", currline);
|
||||
|
||||
fgets(currline, LINESIZE-1, fd);
|
||||
if (tex2)
|
||||
free(tex2);
|
||||
- tex2 = malloc(strlen(currline)+1);
|
||||
- strcpy(tex2, currline);
|
||||
+ len = (strlen(currline)+1);
|
||||
+ tex2 = malloc(len);
|
||||
+ (void)strlcpy(tex2, currline, len);
|
||||
}
|
||||
}
|
||||
fprintf(outfd, "%s", currline);
|
||||
@@ -429,7 +433,7 @@
|
||||
/* if (strcmp(currline, "xi\n") == 0) */
|
||||
if (strstr(currline, "xi\n")) {
|
||||
fprintf(outfd, "%%%s", currline);
|
||||
- strcpy(ps_roff_xi, currline);
|
||||
+ (void)strlcpy(ps_roff_xi, currline, sizeof(ps_roff_xi));
|
||||
}
|
||||
else if (strncmp(currline, "%%Page:", 7) == 0) {
|
||||
fprintf(outfd, "/p { } def\n");
|
||||
@@ -702,6 +706,7 @@
|
||||
FILE *outfd;
|
||||
{
|
||||
|
||||
+ size_t len;
|
||||
Debug(DB_PSROFF, "%%post_onepage: Begin page\n", 0);
|
||||
if (ps_at_trailer) {
|
||||
Debug(DB_PSROFF, "%%post_onepage: still at trailer\n", 0);
|
||||
@@ -754,15 +759,17 @@
|
||||
*/
|
||||
if (tex1)
|
||||
free(tex1);
|
||||
- tex1 = malloc(strlen(currline)+1);
|
||||
- strcpy(tex1, currline);
|
||||
+ len = (strlen(currline)+1);
|
||||
+ tex1 = malloc(len);
|
||||
+ (void)strlcpy(tex1, currline, len);
|
||||
fprintf(outfd, "%s", currline);
|
||||
|
||||
fgets(currline, LINESIZE-1, fd);
|
||||
if (tex2)
|
||||
free(tex2);
|
||||
- tex2 = malloc(strlen(currline)+1);
|
||||
- strcpy(tex2, currline);
|
||||
+ len = (strlen(currline)+1);
|
||||
+ tex2 = malloc(len);
|
||||
+ (void)strlcpy(tex2, currline, len);
|
||||
}
|
||||
}
|
||||
fprintf(outfd, "%s", currline);
|
@ -5,3 +5,4 @@ lib/mpage/ISO-8859.1
|
||||
lib/mpage/ISO+STD+OTH
|
||||
lib/mpage/CP850.PC
|
||||
man/man1/mpage.1
|
||||
@dirrm lib/mpage
|
||||
|
Loading…
Reference in New Issue
Block a user