From: Jeff King Date: Sun, 16 Mar 2014 02:00:19 GMT Subject: Re: [PATCH] mv: prevent mismatched data when ignoring errors. Message-ID: <20140316020018.GA20019@sigill.intra.peff.net> In-Reply-To: <8738ijzbue.fsf@thomasrast.ch> On Sat, Mar 15, 2014 at 05:05:29PM +0100, Thomas Rast wrote: > > diff --git a/builtin/mv.c b/builtin/mv.c > > index f99c91e..b20cd95 100644 > > --- a/builtin/mv.c > > +++ b/builtin/mv.c > > @@ -230,6 +230,11 @@ int cmd_mv(int argc, const char **argv, const char *prefix) > > memmove(destination + i, > > destination + i + 1, > > (argc - i) * sizeof(char *)); > > + memmove(modes + i, modes + i + 1, > > + (argc - i) * sizeof(char *)); > > This isn't right -- you are computing the size of things to be moved > based on a type of char*, but 'modes' is an enum. > > (Valgrind spotted this.) Maybe using sizeof(*destination) and sizeof(*modes) would make this less error-prone? -Peff