[Devel] [PATCH 1/2] Avoid memcpy overruns in fill|load_sigset()

Matt Helsley matthltc at us.ibm.com
Fri Nov 13 15:05:04 PST 2009


Only copy the minimum size of the two structs. I believe gcc
will recognize that these are constants so the resulting code
should be the same size and just as fast.

Signed-off-by: Matt Helsley <matthltc at us.ibm.com>
---
 checkpoint/signal.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/checkpoint/signal.c b/checkpoint/signal.c
index 989b974..c65ee00 100644
--- a/checkpoint/signal.c
+++ b/checkpoint/signal.c
@@ -22,12 +22,12 @@
 
 static inline void fill_sigset(struct ckpt_sigset *h, sigset_t *sigset)
 {
-	memcpy(&h->sigset, sigset, sizeof(*sigset));
+	memcpy(&h->sigset, sigset, min(sizeof(*h), sizeof(*sigset)));
 }
 
 static inline void load_sigset(sigset_t *sigset, struct ckpt_sigset *h)
 {
-	memcpy(sigset, &h->sigset, sizeof(*sigset));
+	memcpy(sigset, &h->sigset, min(sizeof(*h), sizeof(*sigset)));
 }
 
 /***********************************************************************
-- 
1.6.3.3

_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list