[git] GnuPG - branch, master, updated. gnupg-2.1.19-2-ge064c75

by Justus Winter cvs at cvs.gnupg.org
Thu Mar 2 09:34:54 CET 2017


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 GNU Privacy Guard".

The branch, master has been updated
       via  e064c75b08a523f738108428fe0c417a46e66238 (commit)
      from  3cdb7920076be4fc6f7600dfaaa504935104dac9 (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 e064c75b08a523f738108428fe0c417a46e66238
Author: Justus Winter <justus at g10code.com>
Date:   Wed Mar 1 17:47:47 2017 +0100

    common,tools: Always escape newlines when escaping data.
    
    * common/stringhelp.c (do_percent_escape): Always escape newlines.
    * tools/gpgconf-comp.c (gc_percent_escape): Likewise.
    --
    Newlines always pose a problem for a line-based communication format.
    
    GnuPG-bug-id: 2387
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/common/stringhelp.c b/common/stringhelp.c
index 341dd52..bea1466 100644
--- a/common/stringhelp.c
+++ b/common/stringhelp.c
@@ -1052,7 +1052,8 @@ do_percent_escape (const char *str, const char *extra, int die)
     return NULL;
 
   for (i=j=0; str[i]; i++)
-    if (str[i] == ':' || str[i] == '%' || (extra && strchr (extra, str[i])))
+    if (str[i] == ':' || str[i] == '%' || str[i] == '\n'
+        || (extra && strchr (extra, str[i])))
       j++;
   if (die)
     ptr = xmalloc (i + 2 * j + 1);
@@ -1077,6 +1078,13 @@ do_percent_escape (const char *str, const char *extra, int die)
 	  ptr[i++] = '2';
 	  ptr[i++] = '5';
 	}
+      else if (*str == '\n')
+	{
+	  /* The newline is problematic in a line-based format.  */
+	  ptr[i++] = '%';
+	  ptr[i++] = '0';
+	  ptr[i++] = 'a';
+	}
       else if (extra && strchr (extra, *str))
         {
 	  ptr[i++] = '%';
diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c
index d53947e..0c939e5 100644
--- a/tools/gpgconf-comp.c
+++ b/tools/gpgconf-comp.c
@@ -1491,6 +1491,13 @@ gc_percent_escape (const char *src)
 	  *(dst++) = '2';
 	  *(dst++) = 'c';
 	}
+      else if (*src == '\n')
+	{
+	  /* The newline is problematic in a line-based format.  */
+	  *(dst++) = '%';
+	  *(dst++) = '0';
+	  *(dst++) = 'a';
+	}
       else
 	*(dst++) = *(src);
       src++;

-----------------------------------------------------------------------

Summary of changes:
 common/stringhelp.c  | 10 +++++++++-
 tools/gpgconf-comp.c |  7 +++++++
 2 files changed, 16 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list