From nobody Mon Feb 9 03:12:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631293631; cv=none; d=zohomail.com; s=zohoarc; b=ZsXOYm+yCsAbuuj5aABagWfVIUcPUmFQULnlNiYsEDAgpOK6WROaLDhYGbwPWxAOwDb9GLX1PIg5GuO45HpJNVf2OUHo7e0KM5VW0d3Cb9DahyVilozfM2mlW0W/wlhLnaY+IRJCTPpSOKK0Ac0TemLQWlAq5gEPLVMy/Ff/1Qw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631293631; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ZqCkNbuM43KqzBbq91YsLm9a1aNQ2XjTVYVG98V6beo=; b=OMxrAMsf9RY6FrjzNkd2ZMZVk1DdvaGWwtyKaqgWtWlQc+3+7bImvLrastMV6H77+Qm1rF0CJWzzGoHVSybANSMi+/N2co/bMogfDkJ2uuhjspL1oZWw0x6s0C1emjRFDUSU98TmgE9Xj3fmL8u6ghNnworkptWi+9+lpytU8TA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1631293631511383.9306320354374; Fri, 10 Sep 2021 10:07:11 -0700 (PDT) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-84-7nDE0RiCN-ixl4XoTuLFRQ-1; Fri, 10 Sep 2021 13:07:09 -0400 Received: by mail-wm1-f70.google.com with SMTP id m22-20020a7bcb96000000b002f7b840d9dcso834182wmi.1 for ; Fri, 10 Sep 2021 10:07:08 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (21.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.21]) by smtp.gmail.com with ESMTPSA id z1sm4789570wmi.34.2021.09.10.10.07.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 10:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631293630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZqCkNbuM43KqzBbq91YsLm9a1aNQ2XjTVYVG98V6beo=; b=U72k1kPGPfofDIPQERLm83t06Cc2b3+xMV2uKhgW3cirilSowgtQ4MP7h/WJkK3CHEseZL KApkBSwVLmv/EtUqlV9lZRUC/Ob9+wwLqlLXcck56rOv/UrXdLhK9dk98osJzHwj6x6uMl 8HsrsF0SbaySvwGVuW0zH0lgzA8KARI= X-MC-Unique: 7nDE0RiCN-ixl4XoTuLFRQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZqCkNbuM43KqzBbq91YsLm9a1aNQ2XjTVYVG98V6beo=; b=lqFrb9wYgRQ1wMyZv/hhPH/YNlnGsFn522orh0OmtEk+X/oWspAdhUe0ijRN61WO9m 3zDryBuk1Dd9txG6OfWE9FIO1NU9ihy+kzNNSCAWrkCky4soDDyQZdkTGpzDzll7sdKc ZhHKVzm9GevMYE1WsbFBA1Czo3S3Xnr46FC8cm0IBYHsdW+VSYdze7frN2m29JS7WDQd vyNQ3H7jlmHPId0H8s6tu4cZ6BIqv6pGki71TNM5klD4GE/uNcBk67EJZkky9vb4cpb9 T+QhUzWXT3C944xxBy11uZGDIjFvcZlRAJFV9pd7RbHQjcFS4HTjP6wthT8pAzHSxfeR CdBA== X-Gm-Message-State: AOAM530/YOzQqZmG3IwPoWRkHrE7D3teXQVSRsItPj4rjct6U7YUnKX3 wbst4qHPSDpSHvQznCVj0/fSDYZrkg83nBwb+nLbfMNLRAd0ca8MZciitsPVWv1fBer6hBeAdIH QCy6se0bDwkfhdA== X-Received: by 2002:a1c:f315:: with SMTP id q21mr9762001wmq.76.1631293627573; Fri, 10 Sep 2021 10:07:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxp5/JfK+/TzVHdCEfyaUtpwZx22vL4CKuHlqAkJL5PWlNiszGXnrUCo9+WuTknLmHLX2nZyw== X-Received: by 2002:a1c:f315:: with SMTP id q21mr9761974wmq.76.1631293627311; Fri, 10 Sep 2021 10:07:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Viktor Prutyanov , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 2/2] elf2dmp: Fail cleanly if PDB file specifies zero block_size Date: Fri, 10 Sep 2021 19:06:56 +0200 Message-Id: <20210910170656.366592-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210910170656.366592-1-philmd@redhat.com> References: <20210910170656.366592-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631293633704100001 From: Peter Maydell Coverity points out that if the PDB file we're trying to read has a header specifying a block_size of zero then we will end up trying to divide by zero in pdb_ds_read_file(). Check for this and fail cleanly instead. Fixes: Coverity CID 1458869 Signed-off-by: Peter Maydell Reviewed-by: Viktor Prutyanov Message-Id: <20210901143910.17112-3-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Viktor Prutyanov --- Informal T-b tag on https://lore.kernel.org/qemu-devel/20210909004313.1dadb24e@192.168.1.7/ Tested-by: Viktor Prutyanov --- contrib/elf2dmp/pdb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c index b3a65470680..adcfa7e154c 100644 --- a/contrib/elf2dmp/pdb.c +++ b/contrib/elf2dmp/pdb.c @@ -215,6 +215,10 @@ out_symbols: =20 static int pdb_reader_ds_init(struct pdb_reader *r, PDB_DS_HEADER *hdr) { + if (hdr->block_size =3D=3D 0) { + return 1; + } + memset(r->file_used, 0, sizeof(r->file_used)); r->ds.header =3D hdr; r->ds.toc =3D pdb_ds_read(hdr, (uint32_t *)((uint8_t *)hdr + --=20 2.31.1