Skip to content

Commit

Permalink
MFC: Fix a potential buffer overflow in the command line argument par…
Browse files Browse the repository at this point in the history
…sing

	with 'ed [MAXPATHLEN + 1 chars]'. {from revision 1.15}
  • Loading branch information
joe authored and joe committed May 7, 2000
1 parent 09241db commit 8c826b7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bin/ed/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ main(argc, argv)
if (read_file(*argv, 0) < 0 && !isatty(0))
quit(2);
else if (**argv != '!')
strcpy(old_filename, *argv);
if (strlcpy(old_filename, *argv, sizeof(old_filename))
>= sizeof(old_filename))
quit(2);
} else if (argc) {
fputs("?\n", stderr);
if (**argv == '\0')
Expand Down Expand Up @@ -1342,8 +1344,8 @@ strip_escapes(s)
int i = 0;

REALLOC(file, filesz, MAXPATHLEN + 1, NULL);
/* assert: no trailing escape */
while ((file[i++] = (*s == '\\') ? *++s : *s))
while (i < filesz - 1 /* Worry about a possible trailing escape */
&& (file[i++] = (*s == '\\') ? *++s : *s))
s++;
return file;
}
Expand Down

0 comments on commit 8c826b7

Please sign in to comment.