summaryrefslogtreecommitdiffstats
path: root/usr.bin/patch/patch.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/patch/patch.c')
-rw-r--r--usr.bin/patch/patch.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index 1743678..7a53284 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);
OpenPOWER on IntegriCloud