fa3bfd
From f8cef4d07d9641e27629bd3ce2d13f5d702fb251 Mon Sep 17 00:00:00 2001
fa3bfd
From: DJ Delorie <dj@delorie.com>
fa3bfd
Date: Wed, 19 Jul 2017 13:14:34 -0400
fa3bfd
Subject: [PATCH] Fix cast-after-dereference
fa3bfd
fa3bfd
Original code was dereferencing a char*, then casting the value
fa3bfd
to size_t.  Should cast the pointer to size_t* then deference.
fa3bfd
---
fa3bfd
 ChangeLog       | 4 ++++
fa3bfd
 grp/grp-merge.c | 2 +-
fa3bfd
 2 files changed, 5 insertions(+), 1 deletion(-)
fa3bfd
fa3bfd
diff --git a/grp/grp-merge.c b/grp/grp-merge.c
fa3bfd
index 6590e5d..035e7a6 100644
fa3bfd
--- a/grp/grp-merge.c
fa3bfd
+++ b/grp/grp-merge.c
fa3bfd
@@ -137,7 +137,7 @@ __merge_grp (struct group *savedgrp, char *savedbuf, char *savedend,
fa3bfd
 
fa3bfd
   /* Get the count of group members from the last sizeof (size_t) bytes in the
fa3bfd
      mergegrp buffer.  */
fa3bfd
-  savedmemcount = (size_t) *(savedend - sizeof (size_t));
fa3bfd
+  savedmemcount = *(size_t *) (savedend - sizeof (size_t));
fa3bfd
 
fa3bfd
   /* Get the count of new members to add.  */
fa3bfd
   for (memcount = 0; mergegrp->gr_mem[memcount]; memcount++)
fa3bfd
-- 
fa3bfd
1.8.3.1
fa3bfd