diff options
author | Pedro F. Giffuni <pfg@FreeBSD.org> | 2014-06-15 03:54:23 +0000 |
---|---|---|
committer | Pedro F. Giffuni <pfg@FreeBSD.org> | 2014-06-15 03:54:23 +0000 |
commit | c1a08643e3f6c6af2672fc7fd50251465f580489 (patch) | |
tree | d8f74b1b7360c8d7022216091822882c6d2599d8 /usr.bin/patch/patch.c | |
parent | 9945063d708db648a4f21cdaf578883109652001 (diff) |
Notes
Diffstat (limited to 'usr.bin/patch/patch.c')
-rw-r--r-- | usr.bin/patch/patch.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index 1743678626c5..7a5328418118 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -742,14 +742,18 @@ abort_context_hunk(void) static void rej_line(int ch, LINENUM i) { - size_t len; + unsigned short len; const char *line = pfetch(i); - len = strlen(line); + len = strnlen(line, USHRT_MAX); fprintf(rejfp, "%c%s", ch, line); - if (len == 0 || line[len-1] != '\n') - fprintf(rejfp, "\n\\ No newline at end of file\n"); + if (len == 0 || line[len-1] != '\n') { + if (len >= USHRT_MAX) + fprintf(rejfp, "\n\\ Line too long\n"); + else + fprintf(rejfp, "\n\\ No newline at end of line\n"); + } } static void @@ -1016,7 +1020,7 @@ patch_match(LINENUM base, LINENUM offset, LINENUM fuzz) LINENUM pat_lines = pch_ptrn_lines() - fuzz; const char *ilineptr; const char *plineptr; - short plinelen; + unsigned short plinelen; for (iline = base + offset + fuzz; pline <= pat_lines; pline++, iline++) { ilineptr = ifetch(iline, offset >= 0); |