arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1463692-1.patch

147e83
From 4fa8ae49aa169fb8d97882938e8bee3ed9ce5410 Mon Sep 17 00:00:00 2001
147e83
From: DJ Delorie <dj@delorie.com>
147e83
Date: Fri, 14 Jul 2017 21:46:42 -0400
147e83
Subject: [PATCH] Fix BZ #21654 - grp-merge.c alignment
147e83
147e83
* grp/grp_merge.c (__copy_grp): Align char** to minimum pointer
147e83
alignment not char alignment.
147e83
(__merge_grp): Likewise.
147e83
---
147e83
 ChangeLog       |  7 +++++++
147e83
 grp/grp-merge.c | 16 ++++++++++++++++
147e83
 2 files changed, 23 insertions(+)
147e83
147e83
diff --git a/grp/grp-merge.c b/grp/grp-merge.c
147e83
index 77c494d..6590e5d 100644
147e83
--- a/grp/grp-merge.c
147e83
+++ b/grp/grp-merge.c
147e83
@@ -85,6 +85,14 @@ __copy_grp (const struct group srcgrp, const size_t buflen,
147e83
     }
147e83
   members[i] = NULL;
147e83
 
147e83
+  /* Align for pointers.  We can't simply align C because we need to
147e83
+     align destbuf[c].  */
147e83
+  if ((((uintptr_t)destbuf + c) & (__alignof__(char **) - 1)) != 0)
147e83
+    {
147e83
+      uintptr_t mis_align = ((uintptr_t)destbuf + c) & (__alignof__(char **) - 1);
147e83
+      c += __alignof__(char **) - mis_align;
147e83
+    }
147e83
+
147e83
   /* Copy the pointers from the members array into the buffer and assign them
147e83
      to the gr_mem member of destgrp.  */
147e83
   destgrp->gr_mem = (char **) &destbuf[c];
147e83
@@ -168,6 +176,14 @@ __merge_grp (struct group *savedgrp, char *savedbuf, char *savedend,
147e83
   /* Add the NULL-terminator.  */
147e83
   members[savedmemcount + memcount] = NULL;
147e83
 
147e83
+  /* Align for pointers.  We can't simply align C because we need to
147e83
+     align savedbuf[c].  */
147e83
+  if ((((uintptr_t)savedbuf + c) & (__alignof__(char **) - 1)) != 0)
147e83
+    {
147e83
+      uintptr_t mis_align = ((uintptr_t)savedbuf + c) & (__alignof__(char **) - 1);
147e83
+      c += __alignof__(char **) - mis_align;
147e83
+    }
147e83
+
147e83
   /* Copy the member array back into the buffer after the member list and free
147e83
      the member array.  */
147e83
   savedgrp->gr_mem = (char **) &savedbuf[c];
147e83
-- 
147e83
1.8.3.1
147e83