Commit 14121fda authored by Colin Walters's avatar Colin Walters Committed by David Zeuthen
Browse files

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's avatarDavid Zeuthen <zeuthen@gmail.com>
parent 4f7830c4
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment