From nobody Fri Nov 14 16:59:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1588801124; cv=none; d=zohomail.com; s=zohoarc; b=l+unTcIx+EhrRlO6LQ6aTjiNwsEaUWl2Pq9ME5AdOouhaumtWrk2XrzdLcvb1EXaFfGxa4ADX9gjpk0s85QpGYXAGOIHVPjejQ9RqdS9KAMZukjMY1+GWTBmcVHATolwEVuuW97OsgOcKgSL60IgvHWDtsOD30oap9gqqsQyb80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588801124; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject; bh=fJuh9yEQX+2FkhodxnzfqX7Jo2/iC7Lfk8tHnWZtPYg=; b=Mp0LwJ748Wgn2WDBq1TYssGe2KsNZUMv/V3dy/25ku3oU0ny2Mx/2wfuReFEs+FEe77r7R1VRu2tikW5LyVJ2Mw9QTSKuqEmXmZXMEvqlazul35VGTahGmTcGwpLy581B1BLG6X2gOZu6Q3o26K4fQpn702SbaOneMjtnRTRyEo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588801124038368.30217209927116; Wed, 6 May 2020 14:38:44 -0700 (PDT) Received: from localhost ([::1]:38624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jWRkY-00036w-Lg for importer@patchew.org; Wed, 06 May 2020 17:38:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jWRhV-00071Z-7O; Wed, 06 May 2020 17:35:33 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:52688) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jWRhT-0007Qn-H2; Wed, 06 May 2020 17:35:32 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 046LHusM102069; Wed, 6 May 2020 21:35:29 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 30s1gncq0y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 06 May 2020 21:35:29 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 046LHnRw039807; Wed, 6 May 2020 21:35:29 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 30t1r8ss4k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 06 May 2020 21:35:29 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 046LZSpm018020; Wed, 6 May 2020 21:35:28 GMT Received: from localhost.localdomain (/10.74.121.228) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 06 May 2020 14:35:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=fJuh9yEQX+2FkhodxnzfqX7Jo2/iC7Lfk8tHnWZtPYg=; b=oEmzsQGIxSMawk2fAx30Q0UgJU/d0D7TLCwVYlHJD//kpQcRh3z7aB26OdLYcrrXfH/l gfInq3UJdiUA4mXxjfEP8IuL5zwtLeLVIgUuEkNW4DKQD1lUnHD0yQ+hVixstBE1kMq8 VEGRxx9J+mCsisFRGieh0JJ911z6OwnlRqn9YR7zQ9z8U/UTmgGKWwcS2dzbfTitZJWI TwDUofuK6cXtP2BBIuSbZpt8QKRR9DgrV4P8P2eCi+Rq6PSkGdq62NobH5ISRd/PifXK U11TWJFiSBVtTWFgBKWpt7WFdtUUMkzyHyq3Krlk/vjWQBu5KqOWr7mkqTYsPSprtF6B cg== From: Eyal Moscovici To: Subject: [PATCH v2 3/5] qemu-img: validate image length in img_map Date: Thu, 7 May 2020 00:34:57 +0300 Message-Id: <20200506213459.44743-4-eyal.moscovici@oracle.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) In-Reply-To: <20200506213459.44743-1-eyal.moscovici@oracle.com> References: <59b0896d-85ad-08b5-fcc1-36adad7501a4@redhat.com> <20200506213459.44743-1-eyal.moscovici@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9613 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=870 malwarescore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005060172 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9613 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxscore=0 spamscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 phishscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=910 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005060172 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.85; envelope-from=eyal.moscovici@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/06 17:35:22 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Eyal Moscovici , qemu-block@nongnu.org, qemu-devel@nongnu.org, Max Reitz , liran.alon@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The code handles this case correctly we merely skip the loop. However it is probably best to return an explicit error. Acked-by: Mark Kanda Signed-off-by: Eyal Moscovici Reviewed-by: Eric Blake --- qemu-img.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qemu-img.c b/qemu-img.c index 4a06ab7fe8..a1b507a0be 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -3086,6 +3086,11 @@ static int img_map(int argc, char **argv) } =20 length =3D blk_getlength(blk); + if (length < 0) { + error_report("Failed to get size for '%s'", filename); + return 1; + } + while (curr.start + curr.length < length) { int64_t offset =3D curr.start + curr.length; int64_t n; --=20 2.17.2 (Apple Git-113)