]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix regression in username handling (Issue #1145)
authorMichael R Sweet <msweet@msweet.org>
Wed, 4 Jun 2025 14:25:51 +0000 (10:25 -0400)
committerMichael R Sweet <msweet@msweet.org>
Wed, 4 Jun 2025 14:25:51 +0000 (10:25 -0400)
backend/ipp.c

index c0c93956c3bc0725f0f758d1f4247f656527a8ab..26a33b536d798c3c2365e1f9dddacb5835a547d0 100644 (file)
@@ -83,9 +83,9 @@ static int            job_canceled = 0,
                                        /* Job cancelled? */
                        uri_credentials = 0;
                                        /* Credentials supplied in URI? */
-static char            username[256] = "",
+static char            device_username[256] = "",
                                        /* Username for device URI */
-                       *password = NULL;
+                       *device_password = NULL;
                                        /* Password for device URI */
 static const char * const pattrs[] =   /* Printer attributes we want */
 {
@@ -412,7 +412,7 @@ main(int  argc,                             /* I - Number of command-line args */
   */
 
   httpSeparateURI(HTTP_URI_CODING_ALL, device_uri, scheme, sizeof(scheme),
-                  username, sizeof(username), hostname, sizeof(hostname), &port,
+                  device_username, sizeof(device_username), hostname, sizeof(hostname), &port,
                  resource, sizeof(resource));
 
   if (!port)
@@ -637,16 +637,16 @@ main(int  argc,                           /* I - Number of command-line args */
 
   cupsSetPasswordCB2((cups_password_cb2_t)password_cb, &password_tries);
 
-  if (username[0])
+  if (device_username[0])
   {
    /*
     * Use authentication information in the device URI...
     */
 
-    if ((password = strchr(username, ':')) != NULL)
-      *password++ = '\0';
+    if ((device_password = strchr(device_username, ':')) != NULL)
+      *device_password++ = '\0';
 
-    cupsSetUser(username);
+    cupsSetUser(device_username);
     uri_credentials = 1;
   }
   else
@@ -659,11 +659,11 @@ main(int  argc,                           /* I - Number of command-line args */
 
     if (ptr)
     {
-      strlcpy(username, ptr, sizeof(username));
+      strlcpy(device_username, ptr, sizeof(device_username));
       cupsSetUser(ptr);
     }
 
-    password = getenv("AUTH_PASSWORD");
+    device_password = getenv("AUTH_PASSWORD");
   }
 
  /*
@@ -2564,8 +2564,8 @@ monitor_printer(
   http = httpConnect2(monitor->hostname, monitor->port, NULL, AF_UNSPEC,
                       monitor->encryption, 1, 0, NULL);
   httpSetTimeout(http, 30.0, timeout_cb, NULL);
-  if (username[0])
-    cupsSetUser(username);
+  if (device_username[0])
+    cupsSetUser(device_username);
 
   cupsSetPasswordCB2((cups_password_cb2_t)password_cb, &password_tries);
 
@@ -3042,9 +3042,9 @@ password_cb(const char *prompt,           /* I - Prompt (not used) */
 
 
   fprintf(stderr, "DEBUG: password_cb(prompt=\"%s\", http=%p, method=\"%s\", "
-                  "resource=\"%s\", password_tries=%p(%d)), password=%p\n",
-          prompt, http, method, resource, password_tries, *password_tries,
-          password);
+                  "resource=\"%s\", password_tries=%p(%d)), device_password=%p\n",
+          prompt, (void *)http, method, resource, (void *)password_tries, *password_tries,
+          (void *)device_password);
 
   (void)prompt;
   (void)method;
@@ -3067,13 +3067,13 @@ password_cb(const char *prompt,         /* I - Prompt (not used) */
     }
   }
 
-  if (password && *password && *password_tries < 3)
+  if (device_password && *device_password && *password_tries < 3)
   {
     (*password_tries) ++;
 
-    cupsSetUser(username);
+    cupsSetUser(device_username);
 
-    return (password);
+    return (device_password);
   }
   else
   {