From nobody Fri May 17 09:37:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1696118073; cv=none; d=zohomail.com; s=zohoarc; b=IAA2suIsE3HdvzHMuRSMF+mP1K1cqKFEj16yYIqMItmJdffRrMXKxqU7TKz8+41tCY7GdXmlvY1bn4X03sF6YNuOdKMv/PAvvejbORgnBiKTVEX4K9HtMzm7YtTA+NI5sTtvfKjV1nWWEDuL4a6nArlAxC3JrMJ2INtBzT1geBI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696118073; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nvK8BS9ps6tlLgHZB3wvEEtS/WBjeRsiB6ed+WJeDcc=; b=h9tKqOM7bEcbysuP1yPtOmYe2FSAkcoCeUMRnDeB7Wph/beIlQPzfXzS95R8JTLp42Y2Uoks13iQ89n0CfTt5hlWMPYS56ZeHOtqrcGtHSZQtX4RLO0A6lXNqbTR8ovbyN1UGsq3C7vR9uYyaUe/iplYqSvrtOIkpFDoFjLbw7c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696118073297773.090041511101; Sat, 30 Sep 2023 16:54:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qmjm8-0004MS-KF; Sat, 30 Sep 2023 19:53:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qmjm7-0004MH-HD for qemu-devel@nongnu.org; Sat, 30 Sep 2023 19:53:31 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qmjm5-0007vk-W3 for qemu-devel@nongnu.org; Sat, 30 Sep 2023 19:53:31 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-50435a9f800so22976525e87.2 for ; Sat, 30 Sep 2023 16:53:29 -0700 (PDT) Received: from localhost.localdomain (109-252-90-8.nat.spd-mgts.ru. [109.252.90.8]) by smtp.gmail.com with ESMTPSA id h18-20020a197012000000b0050309ea3a62sm4012391lfc.277.2023.09.30.16.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 16:53:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1696118008; x=1696722808; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nvK8BS9ps6tlLgHZB3wvEEtS/WBjeRsiB6ed+WJeDcc=; b=g9aHRkxlVa5nA+jhsQT/Zm4B58s8wllcTZLNuRsWjqDF0tfTvKMjDW2nkQaCgS7rf1 YkP2FTGkJbfhJlqku/1j+u3QF7xhgGSWsnAiWM1OE+FGlSg06SBaTxWe75m34tybrEuj kebgsS0HEJCn7vKSNtTWp1JfUr5Mh7bc8qvv8jY7KAGBNopGWu9GPtOyoLFZvNs/+hnS 5CnTZa26J2Q/GYdrhQMtFobL/sp5RF7vJh7vMBjn6ZYPq83IxyECbYedxYBdnAu/tl3t XhZhuwOtiAsKhKn1Dv0Cb622k8m0/chBulI+Jt8Qd855nMAI9LGd6BoCorjPMoJwlFpO 5MwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696118008; x=1696722808; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nvK8BS9ps6tlLgHZB3wvEEtS/WBjeRsiB6ed+WJeDcc=; b=BmiaDya5QCYoWEaPxgbjWeIRbaW+s+GhI8znBEnqFSsGUAOIAVkADuxjOdC7FiRTO2 iM02h2kTjKKMz1xNw5jbJWyExw0ryrPDtwn12/VcY5/lR+p82SSyXUFkGThSxhclasmL tGCASw3hQQe9PhVxGoj9p6lPXyVDyZJ3J/yYQ0XntY1gXk6eeXPEat1TGpPWUqibHCSs YybimwR8FOIoqbq0K182VbQTUGWVpaoJZbvYjfiWIA+AIit7aaWYi3zVQzp2hW5PdQGy PPYzQFxuqkalvY3soGVkGVbFh5MB9bCN85Fb/7Bg/g4GnbP6XDuh1Q0il/+EVt3NZhcc VblA== X-Gm-Message-State: AOJu0YxoR12NxCVl4FadN5/UwikAK84bboJMoTBc7GvOmKzbv8YtvQKl Rp97bmNUm2wx9L41KgVeJVgYBw== X-Google-Smtp-Source: AGHT+IERyou497UPA6O+bsd/0hugid+ejczsGp74kKQjCABjz8KMWwcjatH0lNBw8TEcuJpRXIWOpQ== X-Received: by 2002:a19:f00e:0:b0:4f9:586b:dba1 with SMTP id p14-20020a19f00e000000b004f9586bdba1mr6379793lfc.4.1696118007916; Sat, 30 Sep 2023 16:53:27 -0700 (PDT) From: Viktor Prutyanov To: peter.maydell@linaro.org Cc: qemu-devel@nongnu.org, akihiko.odaki@daynix.com, yan@daynix.com, viktor@daynix.com, viktor.prutyanov@phystech.edu Subject: [PATCH v2 1/2] elf2dmp: limit print length for sign_rsds Date: Sun, 1 Oct 2023 02:53:16 +0300 Message-Id: <20230930235317.11469-2-viktor@daynix.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230930235317.11469-1-viktor@daynix.com> References: <20230930235317.11469-1-viktor@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: none client-ip=2a00:1450:4864:20::133; envelope-from=viktor@daynix.com; helo=mail-lf1-x133.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696118075104100003 Content-Type: text/plain; charset="utf-8" String sign_rsds isn't terminated, so the print length must be limited. Fixes: Coverity CID 1521598 Signed-off-by: Viktor Prutyanov Reviewed-by: Akihiko Odaki --- contrib/elf2dmp/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c index 5db163bdbe..6de5c9808e 100644 --- a/contrib/elf2dmp/main.c +++ b/contrib/elf2dmp/main.c @@ -478,7 +478,7 @@ static bool pe_check_pdb_name(uint64_t base, void *star= t_addr, } =20 if (memcmp(&rsds->Signature, sign_rsds, sizeof(sign_rsds))) { - eprintf("CodeView signature is \'%.4s\', \'%s\' expected\n", + eprintf("CodeView signature is \'%.4s\', \'%.4s\' expected\n", rsds->Signature, sign_rsds); return false; } --=20 2.21.0 From nobody Fri May 17 09:37:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1696118056; cv=none; d=zohomail.com; s=zohoarc; b=CGCauCxZn7r8LUZGeZzCmNR/hkHr0Yx/sQV9vMmuFkE3OMsR6UYS/3/KfV0FMen33zhpuKmbVUWOYISJGhtHjb6iSNNMwq5Wq5lPdtXt1NL2fa42biOommjPtGAY4cn84B4fEtwa99UnJMhyzLAafv4WUstuo6XiOJJJaxtwtFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696118056; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7UfzjErjTODwvTW2xkD20tjGZ4cTrTpKUNfwuop7eBU=; b=aBK7G/nhzp71tMSGk/XiIX9rRxXNvAWwVOgpslkiJr/hYZWtwpNRAO3QXTehPLMqBZm5dDJvbl74NHkeXNugiqv2LGKSSdSXlgapqvHrEET7Kq+XvuoWR8t17lu+v9U+O5FejKHYGVamE98QSD9OKhjPTXZQIf4xVrHycfiZnpg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696118056132187.63342061417234; Sat, 30 Sep 2023 16:54:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qmjmC-0004NA-52; Sat, 30 Sep 2023 19:53:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qmjm8-0004MT-LR for qemu-devel@nongnu.org; Sat, 30 Sep 2023 19:53:32 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qmjm6-0007vl-0B for qemu-devel@nongnu.org; Sat, 30 Sep 2023 19:53:31 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-5041d6d8b10so24555836e87.2 for ; Sat, 30 Sep 2023 16:53:29 -0700 (PDT) Received: from localhost.localdomain (109-252-90-8.nat.spd-mgts.ru. [109.252.90.8]) by smtp.gmail.com with ESMTPSA id h18-20020a197012000000b0050309ea3a62sm4012391lfc.277.2023.09.30.16.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 16:53:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1696118008; x=1696722808; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7UfzjErjTODwvTW2xkD20tjGZ4cTrTpKUNfwuop7eBU=; b=Cyc42KfmlbvkmMoPonJcDP6gCfhw0pSTehloWojFQWHrH43WsHW0AKiWcFHSmBBGeS 6gBUx+n5pNgU0YU0GWSbAFhH3S9cTdIAcY+9YSNBXIKxf/RK0izFkXnauzkrpkA9PuDi u0k3pQLh6+Js4YEtSET9bznrwCrhKy/m27ZvgQduaamiuWdn0pE8/pQdfGxhd6hKFGEQ ZuVztEUf+mk9+CbxmVGOu1ZVI2nyLP2cBbG15FvDb+v8NtTCLMfypq/s7S+N6wFCzgxF Rctk1xjb/s9uigBoUvpf5k1yUsWARNWCpVklE5t4vpuYDG5oLdyQMxsI8oEPUCuKVY88 JliQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696118008; x=1696722808; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7UfzjErjTODwvTW2xkD20tjGZ4cTrTpKUNfwuop7eBU=; b=wrxYY9MYlqVGAaXiuhPz89a82cVfqvamCUHqij0nNXUgjjvRmWkRw2DLlqPA2ECTef MkSUpricH0XtyXPpYXrH6T4xSvesBdHsymM1g95KC/KjAgLYDdWjcfq1uCvjAeIT2dce ltTQ+o3xnKw8IgEpQscMYVg+KLjWwnhnFQeI/1kUyFzdcY3gW2A9OHev0BhO2IrkYBa+ dc2S1qYgmfvyMARfgYaNPxhfUWOciG36ftpA3Xk0kMGhVReWDutHx8EcHjEsHoLZ4Aen JzAUYB5lQRmA9dM2lcyhozmrnu2WNh4ga/hbXn+0TDGiORQ9vAMqn5hzJ4qw1aSRKaWn mGRQ== X-Gm-Message-State: AOJu0Yz2qIXkuo7HI6xaZhoWWFctjxs//Y82Xi3Fy9aw79G6KEMlJSIu lYV64rNqsyN/GFgWQR/IgXtEL7ohNncW8BVYVE/scQ== X-Google-Smtp-Source: AGHT+IG3i8Qtf6Z3n7Lvg9mHK+fMiAMqnckr7k+r59YC3Gmfdf9qnnw4JsLWr8C2NaB8t+jgYrMEvw== X-Received: by 2002:ac2:4ec8:0:b0:500:79f7:1738 with SMTP id p8-20020ac24ec8000000b0050079f71738mr5430881lfr.17.1696118008452; Sat, 30 Sep 2023 16:53:28 -0700 (PDT) From: Viktor Prutyanov To: peter.maydell@linaro.org Cc: qemu-devel@nongnu.org, akihiko.odaki@daynix.com, yan@daynix.com, viktor@daynix.com, viktor.prutyanov@phystech.edu Subject: [PATCH v2 2/2] elf2dmp: check array bounds in pdb_get_file_size Date: Sun, 1 Oct 2023 02:53:17 +0300 Message-Id: <20230930235317.11469-3-viktor@daynix.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230930235317.11469-1-viktor@daynix.com> References: <20230930235317.11469-1-viktor@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: none client-ip=2a00:1450:4864:20::136; envelope-from=viktor@daynix.com; helo=mail-lf1-x136.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696118057760100003 Content-Type: text/plain; charset="utf-8" Index in file_size array must be checked against num_files, because the entries we are looking for may be absent in the PDB. Fixes: Coverity CID 1521597 Signed-off-by: Viktor Prutyanov Reviewed-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- contrib/elf2dmp/pdb.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c index 6ca5086f02..8e3c18c82f 100644 --- a/contrib/elf2dmp/pdb.c +++ b/contrib/elf2dmp/pdb.c @@ -25,6 +25,10 @@ =20 static uint32_t pdb_get_file_size(const struct pdb_reader *r, unsigned idx) { + if (idx >=3D r->ds.toc->num_files) { + return 0; + } + return r->ds.toc->file_size[idx]; } =20 @@ -159,16 +163,17 @@ static void *pdb_ds_read_file(struct pdb_reader* r, u= int32_t file_number) =20 static int pdb_init_segments(struct pdb_reader *r) { - char *segs; unsigned stream_idx =3D r->segments; =20 - segs =3D pdb_ds_read_file(r, stream_idx); - if (!segs) { + r->segs =3D pdb_ds_read_file(r, stream_idx); + if (!r->segs) { return 1; } =20 - r->segs =3D segs; r->segs_size =3D pdb_get_file_size(r, stream_idx); + if (!r->segs_size) { + return 1; + } =20 return 0; } --=20 2.21.0