From patchwork Sat Oct 13 10:38:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10640107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A68BE14BD for ; Sat, 13 Oct 2018 10:39:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A07E92AE9B for ; Sat, 13 Oct 2018 10:39:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 947192AE9E; Sat, 13 Oct 2018 10:39:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18F252AE9B for ; Sat, 13 Oct 2018 10:39:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726167AbeJMSPk (ORCPT ); Sat, 13 Oct 2018 14:15:40 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:41542 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726097AbeJMSPj (ORCPT ); Sat, 13 Oct 2018 14:15:39 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9DAYD6C081148; Sat, 13 Oct 2018 10:38:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=XCNZ0GJfvZHQ2An1nzHUehCoO3wIyg2XJIWUBXUfyes=; b=FZAQxvbpCcMH/Svd/fsQEfLv3XqczAdpU2mcrZ2Nlx1jKdlzE7kJ2cD7SRpcEEAwqGBL ZbHk3AuI0+xhI95jeYc34CmiOpbLBT8Ub2oaDsHwpRZEZ/pjmuEHYCAeQ9CCBee3sxxy M0YuLZsnzLUW9MvTjk930PvV1HZ2ERRADqHzwqKDUp1yEusA2N+5DbgkBWEvcl169XDB sVmWMRHnuJYUwBARkxuEb6Q6UcB++Bp9wR13bgSULIaASCFZ+Pg98nzwKMrxq83FMLRX ScVtTyghNZkSrCBKnOKdhLhPw/KZ+qGbe5iIp4qqYsKLKQLZhzFghQXtcMVVcnXJHBYT 0Q== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2n38nph8fy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 10:38:49 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9DAcmqf029679 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 10:38:49 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9DAclPv024885; Sat, 13 Oct 2018 10:38:47 GMT Received: from mwanda (/197.232.248.111) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 10:38:47 +0000 Date: Sat, 13 Oct 2018 13:38:40 +0300 From: Dan Carpenter To: "Richard Russon (FlatCap)" Cc: Jens Axboe , linux-ntfs-dev@lists.sourceforge.net, linux-block@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] partitions/ldm: Off by one in ldm_relative() Message-ID: <20181013103840.GA22816@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.10.1 (2018-07-13) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9044 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=766 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810130101 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The > should be >= or otherwise we could end up reading one element beyond the end of the array. Signed-off-by: Dan Carpenter --- block/partitions/ldm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c index 16766f267559..f48bcd2f5226 100644 --- a/block/partitions/ldm.c +++ b/block/partitions/ldm.c @@ -636,7 +636,7 @@ static int ldm_relative(const u8 *buffer, int buflen, int base, int offset) { base += offset; - if (!buffer || offset < 0 || base > buflen) { + if (!buffer || offset < 0 || base >= buflen) { if (!buffer) ldm_error("!buffer"); if (offset < 0)