]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r275553, r275612;
authorpfg <pfg@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 16 Dec 2014 21:13:55 +0000 (21:13 +0000)
committerpfg <pfg@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 16 Dec 2014 21:13:55 +0000 (21:13 +0000)
commit2f2cf8bf623e2df6ca13fa0501a58142f8d44ea1
tree81f2eb8263c48b2958f82750aaa512405ef82c64
parentb876f872dbc6e6f819a87bd1c0003636a6f02bac
MFC r275553, r275612;

patch(1): Bring fixes from OpenBSD

Check fstat return value.  Use off_t for file size and offsets.
Avoid iterating over end of string.

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

git-svn-id: svn://svn.freebsd.org/base/stable/10@275841 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
usr.bin/patch/common.h
usr.bin/patch/pch.c