Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 89ccc1b

Browse files
johnkeepinggitster
authored andcommitted
builtin/mv: fix out of bounds write
When commit a88c915 (mv: move submodules using a gitfile, 2013-07-30) added the submodule_gitfile array, it was not added to the block that enlarges the arrays when we are moving a directory so that we do not have to worry about it being a directory when we perform the actual move. After this, the loop continues over the enlarged set of sources. Since we assume that submodule_gitfile has size argc, if any of the items in the source directory are submodules we are guaranteed to write beyond the end of submodule_gitfile. Fix this by realloc'ing submodule_gitfile at the same time as the other arrays. Reported-by: Guillaume Gelin <[email protected]> Signed-off-by: John Keeping <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7bbc4e8 commit 89ccc1b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

builtin/mv.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
179179
modes = xrealloc(modes,
180180
(argc + last - first)
181181
* sizeof(enum update_mode));
182+
submodule_gitfile = xrealloc(submodule_gitfile,
183+
(argc + last - first)
184+
* sizeof(char *));
182185
}
183186

184187
dst = add_slash(dst);
@@ -192,6 +195,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
192195
prefix_path(dst, dst_len,
193196
path + length + 1);
194197
modes[argc + j] = INDEX;
198+
submodule_gitfile[argc + j] = NULL;
195199
}
196200
argc += last - first;
197201
}

0 commit comments

Comments
 (0)