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;

Reply via email to