From patchwork Fri Aug 31 18:16:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10584323 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 53743112B for ; Fri, 31 Aug 2018 18:21:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42E602C5A7 for ; Fri, 31 Aug 2018 18:21:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35CA12C5A9; Fri, 31 Aug 2018 18:21:54 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D9DCF2C5A7 for ; Fri, 31 Aug 2018 18:21:53 +0000 (UTC) Received: from localhost ([::1]:56134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvo3N-0007RE-5z for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Aug 2018 14:21:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvnwI-0007Gh-RK for qemu-devel@nongnu.org; Fri, 31 Aug 2018 14:14:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvnwG-0005vL-6d for qemu-devel@nongnu.org; Fri, 31 Aug 2018 14:14:34 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50552) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvnwF-0005uu-Sm for qemu-devel@nongnu.org; Fri, 31 Aug 2018 14:14:32 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7VIDeKE061907 for ; Fri, 31 Aug 2018 18:14:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=vTDxGyvVZbHEbIZbP2zN/o73/c3ZDAMAQtl/nrrPfT0=; b=4hu4C/zP/sqzu+CfBSFSj4jp9dlhTr6vAtBoAx4Z+xUlH/ywjpqQv8Xb4DrQGWfmJYa6 Qxcyu9xiTwJVbnl+GjDomn50nuRTf5noeR6i4qJJpblRmrjuB1CNhxD85ddQdVIRsgux 1UCEVhIPf3DSIQBsPtqRDpRHFvrhVV/42QKYAr7dTZGf2QIytrBmj7GfS+a1NdSOnqsJ 5VePhYuJ58my9epBxCoey2PfffnmbbqiReOT1gELGM7Lb842/dBsmCuumM4wdjokp7jH hiSLj9ZScbcOqYia2D6ZyXsTs8Mw4Rkjvo9uDSriTiVVYvnNJRQ9PS/QRZ+BjGbGrii8 6g== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2m2xhucv7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 31 Aug 2018 18:14:31 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7VIEUbT025954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 31 Aug 2018 18:14:30 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7VIEUWx007765 for ; Fri, 31 Aug 2018 18:14:30 GMT Received: from ol7.nl.oracle.com (/10.175.61.138) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 31 Aug 2018 11:14:29 -0700 From: Liam Merwick To: qemu-devel@nongnu.org Date: Fri, 31 Aug 2018 19:16:10 +0100 Message-Id: <1535739372-24454-7-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535739372-24454-1-git-send-email-Liam.Merwick@oracle.com> References: <1535739372-24454-1-git-send-email-Liam.Merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9001 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=806 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808310183 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [PATCH v3 6/8] block: dump_qlist() may dereference a Null pointer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP A NULL 'list' passed into function dump_qlist() isn't correctly validated and can be passed to qlist_first() where it is dereferenced. Given that dump_qlist() is static, and callers already do the right thing, just add an assert to catch future potential bugs. Signed-off-by: Liam Merwick Reviewed-by: Eric Blake --- block/qapi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/qapi.c b/block/qapi.c index c66f949db839..e81be604217c 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -740,6 +740,8 @@ static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation, const QListEntry *entry; int i = 0; + assert(list); + for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++) { QType type = qobject_type(entry->value); bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);