Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipp backend crashes in some cases when printer unavailable #2667

Closed
michaelrsweet opened this Issue Jan 10, 2008 · 2 comments

Comments

Projects
None yet
1 participant
@michaelrsweet
Copy link
Collaborator

michaelrsweet commented Jan 10, 2008

Version: 1.3.5
CUPS.org User: dwb

To avoid the problem of str2656, instead of deleting a printer and defining a class of that name, I changed the printer to print to a new class that contains the real printers. This uncovered a new problem. If the printer in that class that was selected was not accepting jobs, the ipp backend would crash (seg fault on our system).

The problem is in
if (argc == 6 || strcmp(filename, argv[6]))
unlink(filename);
since in this case argc is 7, so it tries to do the strcmp, but the filename variable is set up earlier only if argc is 6.

Note that this statement occurs three times in ipp.c

[I fixed this for our system by deleting the second clause in the "if" statement, but this is not a general solution (we do not use compression).]

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

michaelrsweet commented Jan 23, 2008

CUPS.org User: mike

Fixed in Subversion repository.

There were a bunch of errors in the temporary file handling; the attached patch gets them all...

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

michaelrsweet commented Jan 23, 2008

"str2667.patch":

Index: backend/ipp.c

--- backend/ipp.c (revision 7247)
+++ backend/ipp.c (working copy)
@@ -521,8 +521,8 @@
_("INFO: Unable to contact printer, queuing on next "
"printer in class...\n"));

  •    if (argc == 6 || strcmp(filename, argv[6]))
    
  • unlink(filename);
    
  •    if (tmpfilename[0])
    
  • unlink(tmpfilename);
    
    /*
     * Sleep 5 seconds to keep the job from requeuing too rapidly...
    

    @@ -579,8 +579,8 @@

    if (job_cancelled)
    {

  • if (argc == 6 || strcmp(filename, argv[6]))

  •  unlink(filename);
    
  • if (tmpfilename[0])

  •  unlink(tmpfilename);
    

    return (CUPS_BACKEND_FAILED);
    }
    @@ -765,8 +765,8 @@
    ippDelete(supported);
    httpClose(http);

  •  if (argc == 6 || strcmp(filename, argv[6]))
    
  • unlink(filename);

  •  if (tmpfilename[0])
    
  • unlink(tmpfilename);

    /*

  • Sleep 5 seconds to keep the job from requeuing too rapidly...
    @@ -882,10 +882,18 @@

    • so convert the document to PostScript...
      */
  • if (run_pictwps_filter(argv, filename))

  • if (run_pictwps_filter(argv, files[0]))

  • {

  • if (pstmpname[0])
    
  •   unlink(pstmpname);
    
  • if (tmpfilename[0])
    
  •   unlink(tmpfilename);
    
    • return (CUPS_BACKEND_FAILED);
  •    }
    
  •    filename = pstmpname;
    
  •    files[0] = pstmpname;
    
    /*
    
    • Change the MIME type to application/postscript and change the
      @@ -1681,7 +1689,6 @@

      _cupsLangPrintf(stderr, _("ERROR: Unable to fork pictwpstops: %s\n"),
      strerror(errno));

  • unlink(filename);
    if (ppdfile)
    unlink(ppdfile);
    return (-1);
    @@ -1696,7 +1703,6 @@
    _cupsLangPrintf(stderr, _("ERROR: Unable to wait for pictwpstops: %s\n"),
    strerror(errno));
    close(fd);

  • unlink(filename);
    if (ppdfile)
    unlink(ppdfile);
    return (-1);
    @@ -1716,7 +1722,6 @@
    _cupsLangPrintf(stderr, _("ERROR: pictwpstops exited on signal %d!\n"),
    status);

  • unlink(filename);
    return (status);
    }

@michaelrsweet michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.