summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2000-11-05 03:24:26 +0000
committergad <gad@FreeBSD.org>2000-11-05 03:24:26 +0000
commit97fb9983b4670b7ad0a90b57d836ae8bb7758285 (patch)
tree38be9f7444fc5fc6ceb7fbf68e138c4d19f92453 /usr.sbin/lpr
parent7debc4c274eb1a9c32d875afa71a7d8de7b4b1a0 (diff)
downloadFreeBSD-src-97fb9983b4670b7ad0a90b57d836ae8bb7758285.zip
FreeBSD-src-97fb9983b4670b7ad0a90b57d836ae8bb7758285.tar.gz
Fix potential problem processing jobs from hosts with >32 character hostnames.
This may fix a problem reported by Juha Ylitalo <juha.o.ylitalo@nokia.com>
Diffstat (limited to 'usr.sbin/lpr')
-rw-r--r--usr.sbin/lpr/lpd/printjob.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
index 1095be1..962fae2 100644
--- a/usr.sbin/lpr/lpd/printjob.c
+++ b/usr.sbin/lpr/lpd/printjob.c
@@ -107,7 +107,7 @@ static char title[80]; /* ``pr'' title */
static char locale[80]; /* ``pr'' locale */
static char class[32]; /* classification field */
-static char fromhost[32]; /* user's host machine */
+static char fromhost[MAXHOSTNAMELEN]; /* user's host machine */
/* indentation size in static characters */
static char indent[10] = "-i0";
static char jobname[100]; /* job or file name */
@@ -844,9 +844,12 @@ sendit(pp, file)
i = i * 10 + (*cp++ - '0');
fino = i;
} else if (line[0] == 'H') {
- strcpy(fromhost, line+1);
- if (class[0] == '\0')
+ strncpy(fromhost, line+1, sizeof(fromhost) - 1);
+ fromhost[sizeof(fromhost) - 1] = '\0';
+ if (class[0] == '\0') {
strncpy(class, line+1, sizeof(class) - 1);
+ class[sizeof(class) - 1] = '\0';
+ }
} else if (line[0] == 'P') {
strncpy(logname, line+1, sizeof(logname) - 1);
if (pp->restricted) { /* restricted */
OpenPOWER on IntegriCloud