[git] Pinentry - branch, master, updated. pinentry-0.9.7-52-g8f51108
by Werner Koch
cvs at cvs.gnupg.org
Mon Nov 7 10:56:48 CET 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The standard pinentry collection".
The branch, master has been updated
via 8f51108a17d0080c33fae182f1e4b9259f10a9e5 (commit)
from 15a6fd9f1ee0e3bc62daf143546f5186ce947700 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8f51108a17d0080c33fae182f1e4b9259f10a9e5
Author: Werner Koch <wk at gnupg.org>
Date: Mon Nov 7 08:37:11 2016 +0100
Add fail-safe string termination for snprintf.
* gtk+-2/pinentry-gtk-2.c (changed_text_handler): Make sure an
snprintf buffer is always ternminated.
* pinentry/pinentry.c (my_strusage): Ditto.
(write_status_error): Ditto.
(cmd_getinfo): Ditto.
* w32/main.c (w32_strerror): Ditto.
--
This is to fix the surprising implementation of snprintf on Windows.
Note that we don't need this in GnuPG because there we use our own
snprintf.
Signed-off-by: Werner Koch <wk at gnupg.org>
diff --git a/gtk+-2/pinentry-gtk-2.c b/gtk+-2/pinentry-gtk-2.c
index a7ac91e..6037533 100644
--- a/gtk+-2/pinentry-gtk-2.c
+++ b/gtk+-2/pinentry-gtk-2.c
@@ -398,12 +398,14 @@ changed_text_handler (GtkWidget *widget)
else if (percent < 0)
{
snprintf (textbuf, sizeof textbuf, "(%d%%)", -percent);
+ textbuf[sizeof textbuf -1] = 0;
color.red = 0xffff;
percent = -percent;
}
else
{
snprintf (textbuf, sizeof textbuf, "%d%%", percent);
+ textbuf[sizeof textbuf -1] = 0;
color.green = 0xffff;
}
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (qualitybar),
diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 0023ebe..46e6894 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -604,8 +604,11 @@ my_strusage( int level )
size_t n = 50 + strlen (this_pgmname);
str = malloc (n);
if (str)
- snprintf (str, n, "Usage: %s [options] (-h for help)",
- this_pgmname);
+ {
+ snprintf (str, n, "Usage: %s [options] (-h for help)",
+ this_pgmname);
+ str[n-1] = 0;
+ }
}
p = str;
}
@@ -966,6 +969,7 @@ write_status_error (assuan_context_t ctx, pinentry_t pe)
pe->specific_err_loc? pe->specific_err_loc : "?",
pe->specific_err,
pe->specific_err_info? pe->specific_err_info : "");
+ buf[sizeof buf -1] = 0;
assuan_write_status (ctx, "ERROR", buf);
}
@@ -1435,6 +1439,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
{
snprintf (buffer, sizeof buffer, "%lu", (unsigned long)getpid ());
+ buffer[sizeof buffer -1] = 0;
rc = assuan_send_data (ctx, buffer, strlen (buffer));
}
else if (!strcmp (line, "flavor"))
@@ -1460,6 +1465,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
flags = "";
snprintf (buffer, sizeof buffer, "%s%s", s, flags);
+ buffer[sizeof buffer -1] = 0;
rc = assuan_send_data (ctx, buffer, strlen (buffer));
}
else
diff --git a/w32/main.c b/w32/main.c
index 8c19cb2..b35879d 100644
--- a/w32/main.c
+++ b/w32/main.c
@@ -83,6 +83,7 @@ w32_strerror (int ec)
/* There is only a wchar_t FormatMessage. It does not make much
sense to play the conversion game; we print only the code. */
snprintf (strerr, sizeof strerr, "ec=%d", ec);
+ strerr[sizeof strerr -1] = 0;
#else
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, ec,
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
-----------------------------------------------------------------------
Summary of changes:
gtk+-2/pinentry-gtk-2.c | 2 ++
pinentry/pinentry.c | 10 ++++++++--
w32/main.c | 1 +
3 files changed, 11 insertions(+), 2 deletions(-)
hooks/post-receive
--
The standard pinentry collection
http://git.gnupg.org
More information about the Gnupg-commits
mailing list