cups: don't leak the entered password

This commit is contained in:
Daemonratte 2026-10-17 23:59:00 +02:00
commit cd6e01acde

View file

@ -988,9 +988,9 @@ gtk_print_backend_cups_set_password (GtkPrintBackend *backend,
GList *l;
char dispatch_hostname[HTTP_MAX_URI];
gchar *key;
gchar *username = NULL;
gchar *hostname = NULL;
gchar *password = NULL;
const gchar *username = NULL;
const gchar *hostname = NULL;
const gchar *password = NULL;
gint length;
gint i;
@ -1000,25 +1000,24 @@ gtk_print_backend_cups_set_password (GtkPrintBackend *backend,
for (i = 0; i < length; i++)
{
if (g_strcmp0 (auth_info_required[i], "username") == 0)
username = g_strdup (auth_info[i]);
username = auth_info[i];
else if (g_strcmp0 (auth_info_required[i], "hostname") == 0)
hostname = g_strdup (auth_info[i]);
hostname = auth_info[i];
else if (g_strcmp0 (auth_info_required[i], "password") == 0)
password = g_strdup (auth_info[i]);
password = auth_info[i];
}
if (hostname != NULL && username != NULL && password != NULL)
{
key = g_strconcat (username, "@", hostname, NULL);
g_hash_table_insert (cups_backend->auth, key, g_strdup (password));
GTK_NOTE (PRINTING,
g_print ("CUPS backend: storing password for %s\n", key));
}
g_free (cups_backend->username);
cups_backend->username = g_strdup (username);
GTK_NOTE (PRINTING,
g_print ("CUPS backend: storing password for %s\n", key));
for (l = cups_backend->requests; l; l = l->next)
{
GtkPrintCupsDispatchWatch *dispatch = l->data;
@ -1356,6 +1355,7 @@ request_auth_info (gpointer user_data)
g_free (auth_info_default);
g_free (auth_info_display);
g_free (auth_info_visible);
g_free (printer_name);
g_free (prompt);