From: "Jan Beulich" Subject: [PATCH] bunzip2: off by one in get_next_block() Date: Wed, 28 Jan 2015 15:24:47 +0000 Message-ID: <54C90D4F020000780005A616@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part2411B52F.1__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YGUU7-0000bZ-LM for xen-devel@lists.xenproject.org; Wed, 28 Jan 2015 15:24:51 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Ian Campbell , Keir Fraser , Ian Jackson , Dan Carpenter , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part2411B52F.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline "origPtr" is used as an offset into the bd->dbuf[] array. That array is allocated in start_bunzip() and has "bd->dbufSize" number of elements so the test here should be >=3D instead of >. Later we check "origPtr" again before using it as an offset so I don't know if this bug can be triggered in real life. Signed-off-by: Dan Carpenter Trivial adjustments to make the respective Linux commit b5c8afe5be51078a979d86ae5ae78c4ac948063d apply to Xen. Signed-off-by: Jan Beulich --- a/xen/common/bunzip2.c +++ b/xen/common/bunzip2.c @@ -174,7 +174,7 @@ static int INIT get_next_block(struct bu if (get_bits(bd, 1)) return RETVAL_OBSOLETE_INPUT; origPtr =3D get_bits(bd, 24); - if (origPtr > dbufSize) + if (origPtr >=3D dbufSize) return RETVAL_DATA_ERROR; /* mapping table: if some byte values are never used (encoding = things like ascii text), the compression code removes the gaps to have = fewer --=__Part2411B52F.1__= Content-Type: text/plain; name="bunzip2-off-by-one.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="bunzip2-off-by-one.patch" bunzip2: off by one in get_next_block()=0A=0A"origPtr" is used as an = offset into the bd->dbuf[] array. That array is=0Aallocated in start_bunzi= p() and has "bd->dbufSize" number of elements so=0Athe test here should be = >=3D instead of >.=0A=0ALater we check "origPtr" again before using it as = an offset so I don't=0Aknow if this bug can be triggered in real = life.=0A=0ASigned-off-by: Dan Carpenter =0A=0ATri= vial adjustments to make the respective Linux commit=0Ab5c8afe5be51078a979d= 86ae5ae78c4ac948063d apply to Xen.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/common/bunzip2.c=0A+++ b/xen/common/bunz= ip2.c=0A@@ -174,7 +174,7 @@ static int INIT get_next_block(struct bu=0A = if (get_bits(bd, 1))=0A return RETVAL_OBSOLETE_INPUT;=0A = origPtr =3D get_bits(bd, 24);=0A- if (origPtr > dbufSize)=0A+ if = (origPtr >=3D dbufSize)=0A return RETVAL_DATA_ERROR;=0A /* = mapping table: if some byte values are never used (encoding things=0A = like ascii text), the compression code removes the gaps to have fewer=0A --=__Part2411B52F.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part2411B52F.1__=--