diff options
author | bde <bde@FreeBSD.org> | 1996-09-29 19:12:55 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1996-09-29 19:12:55 +0000 |
commit | b8b5ca939052979e0f92b12099b41b4d9e230ff1 (patch) | |
tree | a8d811e8395222f41a4469ecf48641bd05b715f3 /usr.sbin/lpr/runqueue | |
parent | 2f23ae9a7581d107dcf834182927fa39d9d8c194 (diff) | |
download | FreeBSD-src-b8b5ca939052979e0f92b12099b41b4d9e230ff1.zip FreeBSD-src-b8b5ca939052979e0f92b12099b41b4d9e230ff1.tar.gz |
Close files up to getdtablesize(), instead of up to NOFILE.
lpd was one of 3 programs in /usr/src that (mis)used NOFILE.
Diffstat (limited to 'usr.sbin/lpr/runqueue')
-rw-r--r-- | usr.sbin/lpr/runqueue/printjob.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.sbin/lpr/runqueue/printjob.c b/usr.sbin/lpr/runqueue/printjob.c index 014ccc3..e7e8324 100644 --- a/usr.sbin/lpr/runqueue/printjob.c +++ b/usr.sbin/lpr/runqueue/printjob.c @@ -508,7 +508,7 @@ print(format, file) { register int n; register char *prog; - int fi, fo; + int dtablesize, fi, fo; FILE *fp; char *av[15], buf[BUFSIZ]; int pid, p[2], stopped = 0; @@ -558,7 +558,8 @@ print(format, file) dup2(fi, 0); /* file is stdin */ dup2(p[1], 1); /* pipe is stdout */ closelog(); - for (n = 3; n < NOFILE; n++) + for (n = 3, dtablesize = getdtablesize(); + n < dtablesize; n++) (void) close(n); execl(_PATH_PR, "pr", width, length, "-h", *title ? title : " ", "-F", 0); @@ -680,7 +681,7 @@ start: if (n >= 0) dup2(n, 2); closelog(); - for (n = 3; n < NOFILE; n++) + for (n = 3, dtablesize = getdtablesize(); n < dtablesize; n++) (void) close(n); execv(prog, av); syslog(LOG_ERR, "cannot execv %s", prog); @@ -1027,6 +1028,7 @@ sendmail(user, bombed) int bombed; { register int i; + int dtablesize; int p[2], s; register char *cp; char buf[100]; @@ -1037,7 +1039,7 @@ sendmail(user, bombed) if ((s = dofork(DORETURN)) == 0) { /* child */ dup2(p[0], 0); closelog(); - for (i = 3; i < NOFILE; i++) + for (i = 3, dtablesize = getdtablesize(); i < dtablesize; i++) (void) close(i); if ((cp = rindex(_PATH_SENDMAIL, '/')) != NULL) cp++; @@ -1225,6 +1227,7 @@ static void openpr() { register int i; + int dtablesize; char *cp; if (!remote && *LP) { @@ -1251,7 +1254,8 @@ openpr() dup2(p[0], 0); /* pipe is std in */ dup2(pfd, 1); /* printer is std out */ closelog(); - for (i = 3; i < NOFILE; i++) + for (i = 3, dtablesize = getdtablesize(); + i < dtablesize; i++) (void) close(i); if ((cp = rindex(OF, '/')) == NULL) cp = OF; |