Bryan Steele <bry...@gmail.com> writes:
> No comments about the diff, but shouldn't there be some type here?
>
> clang complains.
>
> warning: type specifier missing, defaults to 'int' [-Wimplicit-int]

Thanks Bryan!

This is so embarrassing. I blame gcc 4.2.1 which silently let this
lunacy through. I developed the patch outside of ports and ./configure
used /usr/bin/gcc by default. Compiling the port surfaces the problem as
you reported... along with 10 other warnings drowning the important
piece.

Thanks
Greg

>From 50687a42962b7eeca3568b2203ec688a75d28dff Mon Sep 17 00:00:00 2001
From: Greg Steuck <g...@nest.cx>
Date: Tue, 13 Oct 2020 20:59:24 -0700
Subject: [PATCH] Replace printf %n with a simple local computation.

---
 security/gnupg/Makefile                      |  2 +-
 security/gnupg/patches/patch-doc_mkdefsinc_c | 28 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 security/gnupg/patches/patch-doc_mkdefsinc_c

diff --git security/gnupg/Makefile security/gnupg/Makefile
index 8a954cf5368..7a46e7eade1 100644
--- security/gnupg/Makefile
+++ security/gnupg/Makefile
@@ -3,7 +3,7 @@
 COMMENT =	GNU privacy guard - a free PGP replacement
 
 DISTNAME =	gnupg-2.2.23
-REVISION =	1
+REVISION =	2
 CATEGORIES = 	security
 
 MASTER_SITES =	${MASTER_SITE_GNUPG:=gnupg/}
diff --git security/gnupg/patches/patch-doc_mkdefsinc_c security/gnupg/patches/patch-doc_mkdefsinc_c
new file mode 100644
index 00000000000..cd0b57e17dc
--- /dev/null
+++ security/gnupg/patches/patch-doc_mkdefsinc_c
@@ -0,0 +1,28 @@
+$OpenBSD$
+
+Avoid %n in snprintf.
+
+Index: doc/mkdefsinc.c
+--- doc/mkdefsinc.c.orig
++++ doc/mkdefsinc.c
+@@ -268,6 +268,7 @@ main (int argc, char **argv)
+   else
+     {
+       const char *month = "?";
++      const int day_of_month = atoi (opt_date+8);
+ 
+       switch (atoi (opt_date+5))
+         {
+@@ -286,10 +287,10 @@ main (int argc, char **argv)
+         }
+       n = strlen (opt_date) + strlen (month) + 2 + 1;
+       p = xmalloc (n);
+-      snprintf (p, n, "%d %n%s %d",
+-                atoi (opt_date+8), &monthoff, month, atoi (opt_date));
++      snprintf (p, n, "%d %s %d", day_of_month, month, atoi (opt_date));
+       xfree (opt_date);
+       opt_date = p;
++      monthoff = 1 + ((day_of_month > 9) ? 2 : 1);  /* good enough log base 10 */
+     }
+ 
+ 
-- 
2.28.0

Reply via email to