=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/patch/patch.c,v retrieving revision 1.25 retrieving revision 1.26 diff -c -r1.25 -r1.26 *** src/usr.bin/patch/patch.c 2003/07/22 20:48:58 1.25 --- src/usr.bin/patch/patch.c 2003/07/23 07:31:21 1.26 *************** *** 1,4 **** ! /* $OpenBSD: patch.c,v 1.25 2003/07/22 20:48:58 millert Exp $ */ /* * patch - a program to apply diffs to original files --- 1,4 ---- ! /* $OpenBSD: patch.c,v 1.26 2003/07/23 07:31:21 otto Exp $ */ /* * patch - a program to apply diffs to original files *************** *** 27,33 **** */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: patch.c,v 1.25 2003/07/22 20:48:58 millert Exp $"; #endif /* not lint */ #include --- 27,33 ---- */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: patch.c,v 1.26 2003/07/23 07:31:21 otto Exp $"; #endif /* not lint */ #include *************** *** 788,795 **** { char *s, R_newline = '\n'; /* Note: string is not null terminated. */ ! for (s=ifetch(line, 0); putc(*s, ofp) != R_newline; s++) ; } --- 788,798 ---- { char *s, R_newline = '\n'; + s = ifetch(line, 0); + if (s == NULL) + return; /* Note: string is not null terminated. */ ! for (; putc(*s, ofp) != R_newline; s++) ; } *************** *** 802,815 **** LINENUM pline = 1 + fuzz; LINENUM iline; LINENUM pat_lines = pch_ptrn_lines() - fuzz; for (iline = base + offset + fuzz; pline <= pat_lines; pline++, iline++) { if (canonicalize) { ! if (!similar(ifetch(iline, (offset >= 0)), ! pfetch(pline), pch_line_len(pline))) return FALSE; ! } else if (strnNE(ifetch(iline, (offset >= 0)), ! pfetch(pline), pch_line_len(pline))) return FALSE; } return TRUE; --- 805,824 ---- LINENUM pline = 1 + fuzz; LINENUM iline; LINENUM pat_lines = pch_ptrn_lines() - fuzz; + char *ilineptr; + char *plineptr; + short plinelen; for (iline = base + offset + fuzz; pline <= pat_lines; pline++, iline++) { + ilineptr = ifetch(iline, offset >= 0); + if (ilineptr == NULL) + return FALSE; + plineptr = pfetch(pline); + plinelen = pch_line_len(pline); if (canonicalize) { ! if (!similar(ilineptr, plineptr, plinelen)) return FALSE; ! } else if (strnNE(ilineptr, plineptr, plinelen)) return FALSE; } return TRUE;