@@ -5449,7 +5449,10 @@ create_local_bg_thread(
54495449 }
54505450 }
54515451
5452- // Validate response from printer...
5452+ /*
5453+ * Validate response from printer...
5454+ */
5455+
54535456 if (!ippValidateAttributes (response ))
54545457 {
54555458 /* Force printer to timeout and be deleted */
@@ -5613,7 +5616,8 @@ create_local_printer(
56135616 char name [128 ], /* Sanitized printer name */
56145617 * nameptr , /* Pointer into name */
56155618 uri [1024 ]; /* printer-uri-supported value */
5616- const char * ptr ; /* Pointer into attribute value */
5619+ const char * ptr , /* Pointer into attribute value */
5620+ * device_uri_ptr ; /* Pointer into device URI value */
56175621 char scheme [HTTP_MAX_URI ], /* Scheme portion of URI */
56185622 userpass [HTTP_MAX_URI ], /* Username portion of URI */
56195623 host [HTTP_MAX_URI ], /* Host portion of URI */
@@ -5683,11 +5687,11 @@ create_local_printer(
56835687 return ;
56845688 }
56855689
5686- ptr = ippGetString (device_uri , 0 , NULL );
5690+ device_uri_ptr = ippGetString (device_uri , 0 , NULL );
56875691
5688- if (!ptr || !ptr [0 ] || (strncmp (ptr , "ipp://" , 6 ) && strncmp (ptr , "ipps://" , 7 )))
5692+ if (!device_uri_ptr || !device_uri_ptr [0 ] || (strncmp (device_uri_ptr , "dnssd://" , 8 ) && strncmp ( device_uri_ptr , " ipp://" , 6 ) && strncmp (device_uri_ptr , "ipps://" , 7 )))
56895693 {
5690- send_ipp_status (con , IPP_STATUS_ERROR_NOT_POSSIBLE , _ ("Bad device-uri \"%s\"." ), ptr );
5694+ send_ipp_status (con , IPP_STATUS_ERROR_NOT_POSSIBLE , _ ("Bad device-uri \"%s\"." ), device_uri_ptr );
56915695
56925696 return ;
56935697 }
@@ -5709,51 +5713,17 @@ create_local_printer(
57095713
57105714 for (printer = (cupsd_printer_t * )cupsArrayFirst (Printers ); printer ; printer = (cupsd_printer_t * )cupsArrayNext (Printers ))
57115715 {
5712- if (printer -> device_uri && !strcmp (ptr , printer -> device_uri ))
5716+ /*
5717+ * Check for a matching device URI...
5718+ */
5719+
5720+ if (printer -> device_uri && !strcmp (device_uri_ptr , printer -> device_uri ))
57135721 {
57145722 printer -> state_time = time (NULL );
57155723 send_ipp_status (con , IPP_STATUS_OK , _ ("Printer \"%s\" already exists." ), printer -> name );
57165724 goto add_printer_attributes ;
57175725 }
5718- /* Check for existing permanent queue with same UUID */
5719- {
5720- cupsd_printer_t * perm ;
5721- char req_uuid [64 ] = "" ;
5722-
5723- /* Extract UUID from hostname like: UUID.local */
5724- const char * host_start = strstr (ptr , "://" );
5725- if (host_start )
5726- {
5727- host_start += 3 ;
5728- const char * dot_local = strstr (host_start , ".local" );
5729- if (dot_local )
5730- {
5731- size_t ulen = (size_t )(dot_local - host_start );
5732- if (ulen < sizeof (req_uuid ))
5733- {
5734- memcpy (req_uuid , host_start , ulen );
5735- req_uuid [ulen ] = '\0' ;
5736- }
5737- }
5738- }
5739-
5740- if (req_uuid [0 ])
5741- {
5742- for (perm = (cupsd_printer_t * )cupsArrayFirst (Printers ); perm ; perm = (cupsd_printer_t * )cupsArrayNext (Printers ))
5743- {
5744- if (!perm -> temporary && perm -> uuid && !strcasecmp (req_uuid , perm -> uuid + 9 ))
5745- {
5746- cupsdLogMessage (CUPSD_LOG_DEBUG , "create_local_printer: FOUND MATCHING PERMANENT QUEUE: %s" , perm -> name );
5747- printer = perm ;
5748- printer -> state_time = time (NULL );
5749- send_ipp_status (con , IPP_STATUS_OK , _ ("Printer \"%s\" already exists." ), printer -> name );
5750- goto add_printer_attributes ;
5751- }
5752- }
5753- }
57545726 }
5755- }
5756-
57575727
57585728 /*
57595729 * Create the printer...
0 commit comments