mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
patch: fix locate_hunk in empty files
if `first_guess' is zero then main() assumes that locate_hunk has failed and aborts the patch operation. Instead, make sure to return 1 (the line number) so that the patch operation can continue. Issue originally found by Neels Hofmeyr in the regress suite of the diff implementation for got, where the tests assume that applying a diff with `patch' and then again with `patch -R' yields back the original file. Obtained from: OpenBSD (CVS patch.c,v 1.71)
This commit is contained in:
parent
970d73856b
commit
7e8afbb6d6
1 changed files with 2 additions and 0 deletions
|
|
@ -717,6 +717,8 @@ locate_hunk(LINENUM fuzz)
|
|||
|| diff_type == UNI_DIFF)) {
|
||||
say("Empty context always matches.\n");
|
||||
}
|
||||
if (first_guess == 0) /* empty file */
|
||||
return 1;
|
||||
return (first_guess);
|
||||
}
|
||||
if (max_neg_offset >= first_guess) /* do not try lines < 0 */
|
||||
|
|
|
|||
Loading…
Reference in a new issue