git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] mv: prevent mismatched data when ignoring errors.

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Mar 11, 2014, 02:00 UTC
Message-ID
<20140311020003.GE4271@vauxhall.crustytoothpaste.net>
In-Reply-To
<20140311015603.GA12180@sigill.intra.peff.net>
On Mon, Mar 10, 2014 at 09:56:03PM -0400, Jeff King wrote:
Show 28 quoted lines
> On Sat, Mar 08, 2014 at 07:21:39PM +0000, brian m. carlson wrote:
> 
> > We shrink the source and destination arrays, but not the modes or
> > submodule_gitfile arrays, resulting in potentially mismatched data.  Shrink
> > all the arrays at the same time to prevent this.
> > 
> > Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> > ---
> >  builtin/mv.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > 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 *));
> > +					memmove(submodule_gitfile + i,
> > +						submodule_gitfile + i + 1,
> > +						(argc - i) * sizeof(char *));
> 
> I haven't looked that closely, but would it be crazy to suggest that
> these arrays all be squashed into one array-of-struct? It would be less
> error prone and perhaps more readable.

I was thinking of doing exactly that, but the way internal_copy_pathspec is written, I'd need to use offsetof to have it write to the right structure members. That's a bit more gross than I wanted, but I'll probably implement it at some point during the upcoming week.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
Previous: Jeff KingNext: Junio C Hamano
Message 9 of 21 in “git 1.9.0 segfault”
  1. Guillaume GelinMar 8, 2014
  2. brian m. carlsonMar 8, 2014
  3. John KeepingMar 8, 2014
  4. builtin/mv: fix out of bounds writeJohn Keeping, Mar 8, 2014
  5. brian m. carlsonMar 8, 2014
  6. builtin/mv: fix out of bounds writeJohn Keeping, Mar 8, 2014
  7. mv: prevent mismatched data when ignoring errors.brian m. carlson, Mar 8, 2014
  8. Jeff KingMar 11, 2014
  9. brian m. carlsonMar 11, 2014
  10. Junio C HamanoMar 11, 2014
  11. brian m. carlsonMar 12, 2014
  12. Thomas RastMar 15, 2014
  13. Jeff KingMar 16, 2014
  14. Junio C HamanoMar 16, 2014
  15. Junio C HamanoMar 17, 2014
  16. Michael HaggertyMar 17, 2014
  17. Eric SunshineMar 17, 2014
  18. Jeff KingMar 17, 2014
  19. Junio C HamanoMar 18, 2014
  20. mv: prevent mismatched data when ignoring errors.brian m. carlson, Mar 15, 2014
  21. Jeff KingMar 16, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.