diff options
Diffstat (limited to 'usr.sbin/lpr')
-rw-r--r-- | usr.sbin/lpr/lpd/printjob.c | 17 | ||||
-rw-r--r-- | usr.sbin/lpr/lpd/recvjob.c | 13 |
2 files changed, 20 insertions, 10 deletions
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c index eded253..9d85f1f3 100644 --- a/usr.sbin/lpr/lpd/printjob.c +++ b/usr.sbin/lpr/lpd/printjob.c @@ -81,6 +81,11 @@ __FBSDID("$FreeBSD$"); #define DOABORT 1 /* dofork should just die if fork() fails */ /* + * The buffer size to use when reading/writing spool files. + */ +#define SPL_BUFSIZ BUFSIZ + +/* * Error tokens */ #define REPRINT -2 @@ -607,7 +612,7 @@ print(struct printer *pp, int format, char *file) register char *prog; int fi, fo; FILE *fp; - char *av[15], buf[BUFSIZ]; + char *av[15], buf[SPL_BUFSIZ]; pid_t wpid; int p[2], retcode, stopped, wstatus, wstatus_set; struct stat stb; @@ -637,7 +642,7 @@ print(struct printer *pp, int format, char *file) if (pp->filters[LPF_INPUT] == NULL && (format == 'f' || format == 'l' || format == 'o')) { pp->tof = 0; - while ((n = read(fi, buf, BUFSIZ)) > 0) + while ((n = read(fi, buf, SPL_BUFSIZ)) > 0) if (write(ofd, buf, n) != n) { (void) close(fi); return (REPRINT); @@ -880,7 +885,7 @@ static int sendit(struct printer *pp, char *file) { int dfcopies, err, i; - char *cp, last[BUFSIZ]; + char *cp, last[sizeof(line)]; /* * open control file @@ -989,7 +994,7 @@ sendfile(struct printer *pp, int type, char *file, char format, int copyreq) int i, amt; struct stat stb; char *av[15], *filtcmd; - char buf[BUFSIZ], opt_c[4], opt_h[4], opt_n[4]; + char buf[SPL_BUFSIZ], opt_c[4], opt_h[4], opt_n[4]; int copycnt, filtstat, narg, resp, sfd, sfres, sizerr, statrc; statrc = lstat(file, &stb); @@ -1150,8 +1155,8 @@ sendagain: */ if (type == '\3') trstat_init(pp, file, job_dfcnt); - for (i = 0; i < stb.st_size; i += BUFSIZ) { - amt = BUFSIZ; + for (i = 0; i < stb.st_size; i += SPL_BUFSIZ) { + amt = SPL_BUFSIZ; if (i + amt > stb.st_size) amt = stb.st_size - i; if (sizerr == 0 && read(sfd, buf, amt) != amt) diff --git a/usr.sbin/lpr/lpd/recvjob.c b/usr.sbin/lpr/lpd/recvjob.c index 37b1044..ac4f9ee 100644 --- a/usr.sbin/lpr/lpd/recvjob.c +++ b/usr.sbin/lpr/lpd/recvjob.c @@ -72,6 +72,11 @@ __FBSDID("$FreeBSD$"); #define ack() (void) write(STDOUT_FILENO, sp, (size_t)1); +/* + * The buffer size to use when reading/writing spool files. + */ +#define SPL_BUFSIZ BUFSIZ + static char dfname[NAME_MAX]; /* data files */ static int minfree; /* keep at least minfree blocks available */ static const char *sp = ""; @@ -255,7 +260,7 @@ static int readfile(struct printer *pp, char *file, size_t size) { register char *cp; - char buf[BUFSIZ]; + char buf[SPL_BUFSIZ]; size_t amt, i; int err, fd, j; @@ -267,8 +272,8 @@ readfile(struct printer *pp, char *file, size_t size) } ack(); err = 0; - for (i = 0; i < size; i += BUFSIZ) { - amt = BUFSIZ; + for (i = 0; i < size; i += SPL_BUFSIZ) { + amt = SPL_BUFSIZ; cp = buf; if (i + amt > size) amt = size - i; @@ -281,7 +286,7 @@ readfile(struct printer *pp, char *file, size_t size) amt -= j; cp += j; } while (amt > 0); - amt = BUFSIZ; + amt = SPL_BUFSIZ; if (i + amt > size) amt = size - i; if (write(fd, buf, amt) != (ssize_t)amt) { |