Page MenuHomeFreeBSD

D57185.id178433.diff
No OneTemporary

D57185.id178433.diff

diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
--- a/usr.sbin/lpr/lpd/printjob.c
+++ b/usr.sbin/lpr/lpd/printjob.c
@@ -208,7 +208,7 @@
* been created by open(). Update &stb to match that new file.
*/
if (statok != 0)
- statok = stat(pp->lock_file, &stb);
+ (void) fstat(lfd, &stb);
/* turn off non-blocking mode (was turned on for lock effects only) */
if (fcntl(lfd, F_SETFL, 0) < 0) {
syslog(LOG_ERR, "%s: fcntl(%s): %m", pp->printer,
@@ -219,8 +219,7 @@
/*
* write process id for others to know
*/
- sprintf(line, "%u\n", printpid);
- pidoff = i = strlen(line);
+ pidoff = i = snprintf(line, sizeof(line), "%u\n", printpid);
if (write(lfd, line, i) != i) {
syslog(LOG_ERR, "%s: write(%s): %m", pp->printer,
pp->lock_file);
@@ -248,9 +247,10 @@
tempstderr);
exit(1);
}
- if ((i = fchmod(tempfd, 0664)) == -1) {
+ if (fchmod(tempfd, 0664) == -1) {
syslog(LOG_ERR, "%s: fchmod(%s): %m", pp->printer,
tempstderr);
+ (void) unlink(tempstderr);
exit(1);
}
/* lpd doesn't need it to be open, it just needs it to exist */
@@ -362,15 +362,18 @@
goto again;
}
-char fonts[4][50]; /* fonts for troff */
+char fonts[4][64]; /* fonts for troff */
-char ifonts[4][40] = {
+char ifonts[4][64] = {
_PATH_VFONTR,
_PATH_VFONTI,
_PATH_VFONTB,
_PATH_VFONTS,
};
+_Static_assert(sizeof(fonts) == sizeof(ifonts), "fonts != ifonts");
+_Static_assert(sizeof(fonts[0]) == sizeof(ifonts[0]), "fonts[0] != ifonts[0]");
+
/*
* The remaining part is the reading of the control file (cf)
* and performing the various actions.
@@ -394,10 +397,9 @@
/*
* Reset troff fonts.
*/
- for (i = 0; i < 4; i++)
- strcpy(fonts[i], ifonts[i]);
+ memcpy(fonts, ifonts, sizeof(fonts));
sprintf(&width[2], "%ld", pp->page_width);
- strcpy(indent+2, "0");
+ strcpy(indent, "-i0");
/* initialize job-specific count of datafiles processed */
job_dfcnt = 0;
@@ -945,7 +947,7 @@
strlcpy(indent+2, line + 1, sizeof(indent) - 2);
} else if (line[0] >= 'a' && line[0] <= 'z') {
dfcopies = 1;
- strcpy(last, line);
+ memcpy(last, line, sizeof(last));
while ((i = get_line(cfp)) != 0) {
if (strcmp(last, line) != 0)
break;

File Metadata

Mime Type
text/plain
Expires
Fri, Jul 24, 2:20 AM (19 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33453631
Default Alt Text
D57185.id178433.diff (2 KB)

Event Timeline