[git] GnuPG - branch, master, updated. gnupg-2.1.15-283-gbc28f32

by NIIBE Yutaka cvs at cvs.gnupg.org
Thu Oct 27 03:18:52 CEST 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  bc28f320fa6f5b9fcdb73dba5e6c582daf7992c5 (commit)
      from  96414baf36b8e6385b71847c789d489ebe176a93 (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 bc28f320fa6f5b9fcdb73dba5e6c582daf7992c5
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Thu Oct 27 10:16:48 2016 +0900

    common: Fix gnupg_inotify_has_name.
    
    * common/sysutils.c (gnupg_inotify_has_name): Take care of the
    alignment.
    
    --
    
    Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>

diff --git a/common/sysutils.c b/common/sysutils.c
index 3a08df7..60483ac 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -1037,40 +1037,48 @@ int
 gnupg_inotify_has_name (int fd, const char *name)
 {
 #if USE_NPTH && HAVE_INOTIFY_INIT
-  union {
-    struct inotify_event ev;
-    char _buf[sizeof (struct inotify_event) + 255 + 1];
-  } buf;
-  struct inotify_event *evp;
+#define BUFSIZE_FOR_INOTIFY (sizeof (struct inotify_event) + 255 + 1)
+  char buf[BUFSIZE_FOR_INOTIFY];
+  char *p;
   int n;
 
-  n = npth_read (fd, &buf, sizeof buf);
+  n = npth_read (fd, buf, sizeof buf);
+  p = buf;
   /* log_debug ("notify read: n=%d\n", n); */
-  evp = &buf.ev;
   while (n >= sizeof (struct inotify_event))
     {
+      struct inotify_event ev;
+      const char *ev_name;
+
+      memcpy (&ev, p, sizeof (struct inotify_event));
+
+      if (ev.len > 255 + 1) /* Something goes wrong, skip this data.  */
+        break;
+
+      ev_name = p + sizeof (struct inotify_event);
+      p += sizeof (struct inotify_event) + ev.len;
+      n -= sizeof (struct inotify_event) + ev.len;
+
       /* log_debug ("             mask=%x len=%u name=(%s)\n", */
-      /*        evp->mask, (unsigned int)evp->len, evp->len? evp->name:""); */
-      if ((evp->mask & IN_UNMOUNT))
+      /*        ev.mask, (unsigned int)ev.len, ev.len? ev.name:""); */
+      if ((ev.mask & IN_UNMOUNT))
         {
           /* log_debug ("             found (dir unmounted)\n"); */
           return 3; /* Directory was unmounted.  */
         }
-      if ((evp->mask & IN_DELETE_SELF))
+      if ((ev.mask & IN_DELETE_SELF))
         {
           /* log_debug ("             found (dir removed)\n"); */
           return 2; /* Directory was removed.  */
         }
-      if ((evp->mask & IN_DELETE))
+      if ((ev.mask & IN_DELETE))
         {
-          if (evp->len >= strlen (name) && !strcmp (evp->name, name))
+          if (ev.len >= strlen (name) && !strcmp (ev_name, name))
             {
               /* log_debug ("             found (file removed)\n"); */
               return 1; /* File was removed.  */
             }
         }
-      n -= sizeof (*evp) + evp->len;
-      evp = (struct inotify_event *)((char*)evp + sizeof (*evp) + evp->len);
     }
 
 #else /*!(USE_NPTH && HAVE_INOTIFY_INIT)*/

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

Summary of changes:
 common/sysutils.c | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)


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




More information about the Gnupg-commits mailing list