Date: Tue, 23 Dec 2014 02:46:01 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r276099 - stable/10/usr.bin/sed Message-ID: <201412230246.sBN2k1Rt026554@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Tue Dec 23 02:46:00 2014 New Revision: 276099 URL: https://svnweb.freebsd.org/changeset/base/276099 Log: MFC r275838; 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) Modified: stable/10/usr.bin/sed/compile.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/sed/compile.c ============================================================================== --- stable/10/usr.bin/sed/compile.c Tue Dec 23 02:14:49 2014 (r276098) +++ stable/10/usr.bin/sed/compile.c Tue Dec 23 02:46:00 2014 (r276099) @@ -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';
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412230246.sBN2k1Rt026554>