I tried to get this upstreamed in https://dev.gnupg.org/T5104 to no
avail. If people find it useful to not see %n related complaints during
the build, the patch below would do it. If desirable, OK?

Thanks
Greg
>From 8afc030e5e22cdcde94437a8b2056ab4c6f16061 Mon Sep 17 00:00:00 2001
From: Greg Steuck <[email protected]>
Date: Wed, 14 Oct 2020 23:49:01 -0700
Subject: [PATCH GnuPG] Avoid printf-%n in mkdefs.c

Replace with an easy computation.
---
 doc/mkdefsinc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/doc/mkdefsinc.c b/doc/mkdefsinc.c
index b8fbed6e9..c8ff90fda 100644
--- a/doc/mkdefsinc.c
+++ b/doc/mkdefsinc.c
@@ -268,6 +268,7 @@ main (int argc, char **argv)
   else
     {
       const char *month = "?";
+      const 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