Skip to content

"git apply" safety

Junio C Hamano git 3 versions New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 0 repliesNew
  2. v34 patches 0 repliesSuperseded
  3. v24 patches 19 repliesSuperseded

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4apply: reject input that touches outside the working areaDocumentation/git-apply.txt builtin/apply.c t/t4139-apply-escape.sh+178 -10 replies
2/4apply: do not read from the filesystem under --indexbuiltin/apply.c+1 -10 replies
3/4apply: do not read from beyond a symbolic linkbuiltin/apply.c t/t4122-apply-symlink-inside.sh+21 -00 replies
4/4apply: do not touch a file beyond a symbolic linkbuiltin/apply.c t/t4122-apply-symlink-inside.sh t/t4139-apply-escape.sh+203 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH v4 0/4] "git apply" safety

Git tracks symbolic links; e.g. you can remove files that have been tracked in a directory "dir/file*" and then creates a symbolic link at "dir" to point elsewhere, express such a change as a patchset and then apply it to the original tree. Consequently, applying a patch to update dir/file, when you have "dir" as a symbolic link pointing somewhere, must fail, just like a patch whose preimage does not match what you have in tree you are trying to apply the patch to gets rejected. Also, we fundamentally do not like to touch a path that contains ".git" as a path component.

This round uses cache_file_exists() in the last patch to cope with case insensitive filesystems better.

The previous round begins here:

http://thread.gmane.org/gmane.comp.version-control.git/263341

Junio C Hamano (4):
apply: reject input that touches outside the working area
apply: do not read from the filesystem under --index
apply: do not read from beyond a symbolic link
apply: do not touch a file beyond a symbolic link

 Documentation/git-apply.txt     |  12 +++-
 builtin/apply.c                 | 142 +++++++++++++++++++++++++++++++++++++++-
 t/t4122-apply-symlink-inside.sh | 106 ++++++++++++++++++++++++++++++
 t/t4139-apply-escape.sh         | 141 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 399 insertions(+), 2 deletions(-)
 create mode 100755 t/t4139-apply-escape.sh
Signature · 1 line
2.3.0-185-g073f588