Hi,
I seem to remember other code guarantees that lines are always
termined by '\n'. Specifically plan_a(), plan_b() and ifetch();
-Otto
On Tue, Nov 18, 2014 at 03:27:27PM +0100, Tobias Stoeckmann wrote:
> Hi,
>
> on a diff with a missing new line, it is possible that patch will read
> past the terminating NUL character.
>
>
> Tobias
>
> Index: pch.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/patch/pch.c,v
> retrieving revision 1.42
> diff -u -p -r1.42 pch.c
> --- pch.c 17 Nov 2014 10:58:09 -0000 1.42
> +++ pch.c 18 Nov 2014 14:25:31 -0000
> @@ -344,9 +344,9 @@ intuit_diff_type(void)
> ok_to_create_file = true;
> /*
> * If this is a new context diff the character just
> - * before the newline is a '*'.
> + * at the end of the line is a '*'.
> */
> - while (*s != '\n')
> + while (*s && *s != '\n')
> s++;
> p_indent = indent;
> p_start = previous_line;