svn commit: r275838 - head/usr.bin/sed
Pedro F. Giffuni
pfg at FreeBSD.org
Tue Dec 16 20:26:12 UTC 2014
Author: pfg
Date: Tue Dec 16 20:26:11 2014
New Revision: 275838
URL: https://svnweb.freebsd.org/changeset/base/275838
Log:
sed: Bounds check the file path used in the 'w' command.
Modified version of a diff from Sebastien Marie to prevent a crash found
with the afl fuzzer.
Obtained from: OpenBSD (CVS Rev. 1.37)
MFC after: 1 week
Modified:
head/usr.bin/sed/compile.c
Modified: head/usr.bin/sed/compile.c
==============================================================================
--- head/usr.bin/sed/compile.c Tue Dec 16 20:05:10 2014 (r275837)
+++ head/usr.bin/sed/compile.c Tue Dec 16 20:26:11 2014 (r275838)
@@ -558,7 +558,7 @@ compile_flags(char *p, struct s_subst *s
{
int gn; /* True if we have seen g or n */
unsigned long nval;
- char wfile[_POSIX2_LINE_MAX + 1], *q;
+ char wfile[_POSIX2_LINE_MAX + 1], *q, *eq;
s->n = 1; /* Default */
s->p = 0;
@@ -611,9 +611,12 @@ compile_flags(char *p, struct s_subst *s
#endif
EATSPACE();
q = wfile;
+ eq = wfile + sizeof(wfile) - 1;
while (*p) {
if (*p == '\n')
break;
+ if (q >= eq)
+ err(1, "wfile too long");
*q++ = *p++;
}
*q = '\0';
More information about the svn-src-all
mailing list