From: Michael R Sweet Date: Wed, 4 Jun 2025 14:25:51 +0000 (-0400) Subject: Fix regression in username handling (Issue #1145) X-Git-Tag: v2.4.13~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=430fc9044d4eb6a500a5e54ac20d4a7b44685d0e;p=thirdparty%2Fcups.git Fix regression in username handling (Issue #1145) --- diff --git a/backend/ipp.c b/backend/ipp.c index c0c93956c3..26a33b536d 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -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 {