From kcwu@camel.ck.tp.edu.tw  Mon Apr 24 03:20:14 2000
Return-Path: <kcwu@camel.ck.tp.edu.tw>
Received: from camel.ck.tp.edu.tw (camel.ck.tp.edu.tw [203.64.26.1])
	by hub.freebsd.org (Postfix) with ESMTP id 1412737BA82
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 24 Apr 2000 03:20:13 -0700 (PDT)
	(envelope-from kcwu@camel.ck.tp.edu.tw)
Received: (from kcwu@localhost)
	by camel.ck.tp.edu.tw (8.9.3/8.9.3) id SAA07197;
	Mon, 24 Apr 2000 18:19:51 +0800 (CST)
	(envelope-from kcwu)
Message-Id: <200004241019.SAA07197@camel.ck.tp.edu.tw>
Date: Mon, 24 Apr 2000 18:19:51 +0800 (CST)
From: Kuang-che Wu <kcwu@camel.ck.tp.edu.tw>
Reply-To: kcwu@camel.ck.tp.edu.tw
To: FreeBSD-gnats-submit@freebsd.org
Subject: pac core dumped
X-Send-Pr-Version: 3.2

>Number:         18191
>Category:       bin
>Synopsis:       pac core dumped without set /etc/printcap
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 24 03:30:01 PDT 2000
>Closed-Date:    Sun Feb 25 05:50:35 PST 2001
>Last-Modified:  Sun Feb 25 05:51:34 PST 2001
>Originator:     Kuang-che Wu
>Release:        FreeBSD 4.0-STABLE i386
>Organization:
Chien-kuo Senior High School
>Environment:

FreeBSD camel.ck.tp.edu.tw 4.0-STABLE FreeBSD 4.0-STABLE #0: Sat Apr 22 08:20:49
 CST 2000     root@camel.ck.tp.edu.tw:/usr/local/bsdsrc/sys/compile/camel  i386

>Description:

If "af=" field not set in /etc/printcap,
run /usr/sbin/pac will get core dumped

NOTE: this problem exists in every version of FreeBSD

>How-To-Repeat:

# pac
Segmentation fault (core dumped)

>Fix:

--- /usr/src/usr.sbin/lpr/pac/pac.c.orig	Mon Apr 24 18:02:20 2000
+++ /usr/src/usr.sbin/lpr/pac/pac.c	Mon Apr 24 18:09:39 2000
@@ -180,6 +180,11 @@
 		exit(2);
 	}
 
+	if (acctfile == NULL) {
+		printf("pac: acct.file of printer %s didn't set in printcap\n", 
+		printer);
+		exit(1);
+	}
 	if ((acct = fopen(acctfile, "r")) == NULL) {
 		perror(acctfile);
 		exit(1);
@@ -453,10 +458,12 @@
 	acctfile = pp->acct_file;
 	if (!pflag && pp->price100)
 		price = pp->price100/10000.0;
-	sumfile = (char *) calloc(sizeof(char), strlen(acctfile)+5);
-	if (sumfile == NULL)
-		errx(1, "calloc failed");
-	strcpy(sumfile, acctfile);
-	strcat(sumfile, "_sum");
+	if (acctfile) {
+		sumfile = (char *) calloc(sizeof(char), strlen(acctfile)+5);
+		if (sumfile == NULL)
+			errx(1, "calloc failed");
+		strcpy(sumfile, acctfile);
+		strcat(sumfile, "_sum");
+	}
 	return(1);
 }



>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: dwmalone 
State-Changed-When: Sun Feb 25 05:50:35 PST 2001 
State-Changed-Why:  
Thanks for the patch. We've committed something similar ot -current 
and I'll merge it before 4.3 is released if all goes well. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=18191 
>Unformatted:
