From cd6e01acde8e6c28c1dcd8ec5fb275c7d72ae15f Mon Sep 17 00:00:00 2001 From: Daemonratte Date: Sat, 17 Oct 2026 23:59:00 +0200 Subject: [PATCH] cups: don't leak the entered password --- .../printbackends/cups/gtkprintbackendcups.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c index 61b72e63b..176cb1d01 100644 --- a/modules/printbackends/cups/gtkprintbackendcups.c +++ b/modules/printbackends/cups/gtkprintbackendcups.c @@ -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);