Index: berkeley/lpq.c =================================================================== --- berkeley/lpq.c (revision 8404) +++ berkeley/lpq.c (working copy) @@ -3,7 +3,7 @@ * * "lpq" command for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -372,17 +372,13 @@ request = ippNewRequest(id ? IPP_GET_JOB_ATTRIBUTES : IPP_GET_JOBS); - if (dest == NULL) + if (id) { - if (id) - sprintf(resource, "ipp://localhost/jobs/%d", id); - else - strcpy(resource, "ipp://localhost/jobs"); - + snprintf(resource, sizeof(resource), "ipp://localhost/jobs/%d", id); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, resource); } - else + else if (dest) { httpAssembleURIf(HTTP_URI_CODING_ALL, resource, sizeof(resource), "ipp", NULL, "localhost", 0, "/printers/%s", dest); @@ -390,6 +386,9 @@ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, resource); } + else + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", + NULL, "ipp://localhost/"); if (user) {