Commit 9db0571
committed
apply --reject: overwrite existing
The `git apply --reject` is expected to write out `.rej` files in case
one or more hunks fail to apply cleanly. Historically, the command
overwrites any existing `.rej` files. The idea being that
apply/reject/edit cycles are relatively common, and the generated `.rej`
files are not considered precious.
But the command does not overwrite existing `.rej` symbolic links, and
instead follows them. This is unsafe because the same patch could
potentially create such a symbolic link and point at arbitrary paths
outside the current worktree, and `git apply` would write the contents
of the `.rej` file into that location.
Therefore, let's make sure that any existing `.rej` file or symbolic
link is removed before writing it.
Reported-by: RyotaK <[email protected]>
Helped-by: Taylor Blau <[email protected]>
Helped-by: Junio C Hamano <[email protected]>
Helped-by: Linus Torvalds <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>.rej symlink if it exists1 parent 2f3b28f commit 9db0571
2 files changed
+27
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4558 | 4558 | | |
4559 | 4559 | | |
4560 | 4560 | | |
4561 | | - | |
| 4561 | + | |
4562 | 4562 | | |
4563 | 4563 | | |
4564 | 4564 | | |
| |||
4598 | 4598 | | |
4599 | 4599 | | |
4600 | 4600 | | |
4601 | | - | |
| 4601 | + | |
| 4602 | + | |
| 4603 | + | |
| 4604 | + | |
| 4605 | + | |
| 4606 | + | |
| 4607 | + | |
| 4608 | + | |
| 4609 | + | |
| 4610 | + | |
| 4611 | + | |
4602 | 4612 | | |
4603 | 4613 | | |
4604 | 4614 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
128 | 143 | | |
0 commit comments