[Devel] Re: [PATCH 1/2] Avoid memcpy overruns in fill|load_sigset()
Oren Laadan
orenl at cs.columbia.edu
Mon Nov 16 10:43:21 PST 2009
struct ckpt_sigset is defined to match the size of sigset_t.
Compilation should fail if it does not. Am I missing something ?
Oren.
Matt Helsley wrote:
> 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)));
> }
>
> /***********************************************************************
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
More information about the Devel
mailing list