Bug 3899

Summary: lpd fails to create valid temporary file names when reading the jobs queue
Product: [Retired] Red Hat Linux Reporter: nick
Component: lprAssignee: David Lawrence <dkl>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-07-06 15:10:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description nick 1999-07-05 13:45:33 UTC
Two fixes applied to printjob.c from lpr-0.35 (the first is
just good practice).  Original file on left, new file on
right.

771,772c771,776
< 	    dup_cfpname = strdup(file);
< 	    memcpy((dup_cfpname+7), "XXXXXX", 6);
---
> 	    if (!(dup_cfpname = strdup(file)))
> 	      {
> 		syslog(LOG_ERR, "Can't allocate memory for temp cfp file
name");> 		return(OK);
> 	      }
> 	    memcpy((dup_cfpname+strlen(dup_cfpname)-6), "XXXXXX",
6);


First fix checks that there was memory available for the
strdup.
Second fix ensures that mktemp has exactly 6 X's at the end
of the string in which to make the filename unique.  NOTE:
It would be better to use mkstemp rather than mktemp.

I hope this makes sense but drop me a line if it does not.

Regards

Nick SS

Comment 1 Bill Nottingham 1999-07-06 15:10:59 UTC
we aren't using mkstemp because we're just trying to make
a temporary file name, not open it.

in any case, this is fixed in lpr >= 0.36.