[git] GnuPG - branch, master, updated. gnupg-2.1.16-81-g5c7d582

by Werner Koch cvs at cvs.gnupg.org
Thu Dec 8 20:29:08 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 GNU Privacy Guard".

The branch, master has been updated
       via  5c7d58222834793629a30248e72b6ea96e832dc4 (commit)
      from  cb4c7abb774e2d95806d8b0ec6ea5cd130c1b5b8 (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 5c7d58222834793629a30248e72b6ea96e832dc4
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Dec 8 20:25:48 2016 +0100

    common: Skip the Byte Order Mark in conf files.
    
    * common/argparse.c (optfile_parse): Detect and skip the UTF-8 BOM.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/common/argparse.c b/common/argparse.c
index 240fdce..dce725a 100644
--- a/common/argparse.c
+++ b/common/argparse.c
@@ -568,17 +568,35 @@ optfile_parse (FILE *fp, const char *filename, unsigned *lineno,
   char *buffer = NULL;
   size_t buflen = 0;
   int in_alias=0;
+  int unread_buf[3];  /* We use an int so that we can store EOF.  */
+  int unread_buf_count = 0;
 
   if (!fp) /* Divert to to arg_parse() in this case.  */
     return arg_parse (arg, opts);
 
   initialize (arg, filename, lineno);
 
+  /* If the LINENO is zero we assume that we are at the start of a
+   * file and we skip over a possible Byte Order Mark.  */
+  if (!*lineno)
+    {
+      unread_buf[0] = getc (fp);
+      unread_buf[1] = getc (fp);
+      unread_buf[2] = getc (fp);
+      if (unread_buf[0] != 0xef
+          || unread_buf[1] != 0xbb
+          || unread_buf[2] != 0xbf)
+        unread_buf_count = 3;
+    }
+
   /* Find the next keyword.  */
   state = i = 0;
   for (;;)
     {
-      c = getc (fp);
+      if (unread_buf_count)
+        c = unread_buf[3 - unread_buf_count--];
+      else
+        c = getc (fp);
       if (c == '\n' || c== EOF )
         {
           if ( c != EOF )

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

Summary of changes:
 common/argparse.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)


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




More information about the Gnupg-commits mailing list