diff options
author | pfg <pfg@FreeBSD.org> | 2014-12-08 15:10:48 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2014-12-08 15:10:48 +0000 |
commit | b65c58c802436598f59e45644da19df91a0da8cf (patch) | |
tree | 3c269ee9ccfa4cd3d101b13956526b5b9fe2c7ff /usr.bin/patch/common.h | |
parent | 663f808a46cfb5d6fe438698225c4d545199c028 (diff) | |
download | FreeBSD-src-b65c58c802436598f59e45644da19df91a0da8cf.zip FreeBSD-src-b65c58c802436598f59e45644da19df91a0da8cf.tar.gz |
patch(1): avoid line number overflows
Introduce strtolinenum to properly check line numbers while parsing:
no signs, no spaces, just digits, 0 <= x <= LONG_MAX
Properly validate line ranges supplied in diff file to prevent overflows.
Also fixes an out of boundary memory access because the resulting values
are used as array indices.
PR: 195436
Obtained from: OpenBSD (CVS pch.c rev 1.45, 1,46, common.h rev 1.28)
MFC after: 1 week
Diffstat (limited to 'usr.bin/patch/common.h')
-rw-r--r-- | usr.bin/patch/common.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h index a6da179..8963c83 100644 --- a/usr.bin/patch/common.h +++ b/usr.bin/patch/common.h @@ -40,6 +40,7 @@ #define INITHUNKMAX 125 /* initial dynamic allocation size */ #define INITLINELEN 4096 #define BUFFERSIZE 4096 +#define LINENUM_MAX LONG_MAX #define SCCSPREFIX "s." #define GET "get -e %s" |