PolicyKit: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Wed Jun 6 10:29:19 PDT 2012


 src/polkitagent/polkitagenthelper-pam.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 14121fda7e4fa9463c66ce419cc32be7e7f3b535
Author: Colin Walters <walters at verbum.org>
Date:   Wed Jun 6 09:05:14 2012 -0400

    agenthelper-pam: Fix newline-trimming code
    
    First, we were using == instead of =, as the author probably intended.
    But after changing that, we're now assigning to const memory.  Fix
    that by writing to a temporary string buffer.
    
    Signed-off-by: David Zeuthen <zeuthen at gmail.com>

diff --git a/src/polkitagent/polkitagenthelper-pam.c b/src/polkitagent/polkitagenthelper-pam.c
index 85a2671..7af5321 100644
--- a/src/polkitagent/polkitagenthelper-pam.c
+++ b/src/polkitagent/polkitagenthelper-pam.c
@@ -227,6 +227,8 @@ conversation_function (int n, const struct pam_message **msg, struct pam_respons
   char buf[PAM_MAX_RESP_SIZE];
   int i;
   gchar *escaped = NULL;
+  gchar *tmp = NULL;
+  size_t len;
 
   data = data;
   if (n <= 0 || n > PAM_MAX_NUM_MSG)
@@ -258,9 +260,12 @@ conversation_function (int n, const struct pam_message **msg, struct pam_respons
 #ifdef PAH_DEBUG
           fprintf (stderr, "polkit-agent-helper-1: writing `%s' to stdout\n", msg[i]->msg);
 #endif /* PAH_DEBUG */
-          if (strlen (msg[i]->msg) > 0 && msg[i]->msg[strlen (msg[i]->msg) - 1] == '\n')
-            msg[i]->msg[strlen (msg[i]->msg) - 1] == '\0';
-          escaped = g_strescape (msg[i]->msg, NULL);
+          tmp = g_strdup (msg[i]->msg);
+          len = strlen (tmp);
+          if (len > 0 && tmp[len - 1] == '\n')
+            tmp[len - 1] = '\0';
+          escaped = g_strescape (tmp, NULL);
+          g_free (tmp);
           fputs (escaped, stdout);
           g_free (escaped);
 #ifdef PAH_DEBUG


More information about the hal-commit mailing list