Mercurial > public > mercurial-scm > hg-stable
diff mercurial/diffhelpers.py @ 37573:49b82cdb5983
patch: error out if reached to EOF while reading hunk
This was where out-of-bounds read occurred in old C extension.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 09 Apr 2018 21:06:46 +0900 |
parents | c6b8d614690a |
children | a1bcc7ff0eac |
line wrap: on
line diff
--- a/mercurial/diffhelpers.py Mon Apr 09 20:55:05 2018 +0900 +++ b/mercurial/diffhelpers.py Mon Apr 09 21:06:46 2018 +0900 @@ -7,6 +7,12 @@ from __future__ import absolute_import +from .i18n import _ + +from . import ( + error, +) + def addlines(fp, hunk, lena, lenb, a, b): """Read lines from fp into the hunk @@ -22,6 +28,8 @@ break for i in xrange(num): s = fp.readline() + if not s: + raise error.ParseError(_('incomplete hunk')) if s == "\\ No newline at end of file\n": fixnewline(hunk, a, b) continue