[Devel] Re: [PATCH 1/2] Avoid memcpy overruns in fill|load_sigset()
Matt Helsley
matthltc at us.ibm.com
Tue Nov 17 14:45:33 PST 2009
On Mon, Nov 16, 2009 at 01:43:21PM -0500, Oren Laadan wrote:
>
> struct ckpt_sigset is defined to match the size of sigset_t.
> Compilation should fail if it does not. Am I missing something ?
OK, I didn't see where it would cause compilation to fail. That's
better than this patch which would "fail" silently if they differ.
Cheers,
-Matt
>
> 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