Bug 496008 - Memory leak can occur in cupsd if `file' devices are configured
Memory leak can occur in cupsd if `file' devices are configured
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: cups (Show other bugs)
All Linux
low Severity medium
: ---
: ---
Assigned To: Tim Waugh
Depends On:
  Show dependency treegraph
Reported: 2009-04-15 19:08 EDT by Opher Shachar
Modified: 2010-03-30 04:15 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 536741 (view as bug list)
Last Closed: 2010-03-30 04:15:15 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2010:0210 normal SHIPPED_LIVE cups bug fix update 2010-03-29 08:29:38 EDT

  None (edit)
Description Opher Shachar 2009-04-15 19:08:09 EDT
Description of problem:
As shipped in RHEL5.3 cups-1.3.7-8 is compiled `with-lspp'.
The lspp patch for scheduler/printers.c adds this code to cupsdSetPrinterAttrs():

      printerfile = strstr(p->device_uri, "/dev/");
      if (printerfile == NULL && (strncmp(p->device_uri, "file:/", 6) == 0))
        printerfile = strdup(p->device_uri + strlen("file:/"));

Note that in the first line printerfile is made to point into an existing string, and in the third line a *new* string is allocated with strdup() - and the code does *not* free it. Also note that this duplicated sub-string is wrong: It does not include the first `/'.

A possible fix is to change the third line to:

        printerfile = p->device_uri + 5;

Version-Release number of selected component (if applicable):

Steps to Reproduce:
1. In /etc/cups/cupsd.conf set:
   FileDevice Yes
2. Restart cups
3. lpadmin -p "Create Postscript file" -v file:/home/opher/dump.ps -m postscript.ppd.gz -E
4. In /etc/cups/cupsd.conf set:
   FileDevice No
5. Restart cups

Additional info:
I'm not sure when and where cupsdSetPrinterAttrs() is called and hence how much memory is leaking ... but this should be fixed.

Also, if we're at it, my system (RHEL5) is installed with selinux *disabled* so every cups restart I get this:

    E [16/Apr/2009:01:35:08 +0300] cupsdSetPrinterAttrs: Unable to get printer context

for every configured printer (225 printers currently) that have a device uri: file:/dev/null
Could you check that selinux is enabled before you log the error?

Comment 1 Tim Waugh 2009-05-15 07:04:43 EDT
Thanks for spotting this and reporting it.
Comment 7 errata-xmlrpc 2010-03-30 04:15:15 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


Note You need to log in before you can comment on or make changes to this bug.