Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nuJCK-0000Lu-CV for mharc-grub-devel@gnu.org; Thu, 26 May 2022 15:31:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuJCB-0000Kz-Pm for grub-devel@gnu.org; Thu, 26 May 2022 15:30:57 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:43438) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuJC8-0004O7-3X for grub-devel@gnu.org; Thu, 26 May 2022 15:30:55 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24QHNG9h019658 for ; Thu, 26 May 2022 19:29:49 GMT 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-2021-07-09; bh=aRsP5KeKyfMHlV6EKyPgTEfHrMmOnR5MuuLrVUr+ir4=; b=UR3WAw9KTPjZW6Dv1WcPrPILaCU7CUztFVEjVjmMG8AXXQPWdeHS4Z70eZxNBh3KUoCG 7oZ8mjqO5ee2uxm9bB1hcuQPicKoflPKXF1/5W3B3elT3TQRsY7xUVqrEbbLkx2qAciq nNenvLhah2brbIuveIhXud82nT2JemufEKsQXqqspfiZFPQ2McpXat6su+oDaVEmcMTJ jbcwHQiXDbsNmKeObcad30PasLW2A6dHAOqHxZ8rT8bbFbkNoIRf7Hs8JCYDAtF9j+9M oooUxq4wfKu0Hf7Dpaa2oUCUayRjpsFtVNvSvP5vckuHUyzZl2EAO7rQuuaSLb1ohdeW qg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3g93tawrrb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 26 May 2022 19:29:49 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 24QJSUGW002165 for ; Thu, 26 May 2022 19:29:47 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3g93wwkd8d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 26 May 2022 19:29:47 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 24QJTlCK003844 for ; Thu, 26 May 2022 19:29:47 GMT Received: from localhost (dhcp-10-152-14-18.usdhcp.oraclecorp.com [10.152.14.18]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3g93wwkd87-1; Thu, 26 May 2022 19:29:47 +0000 From: Alec Brown To: grub-devel@gnu.org Cc: daniel.kiper@oracle.com, darren.kenny@oracle.com, alec.r.brown@oracle.com Subject: [PATCH 6/6] util/grub-module-verifierXX.c: Changed get_shnum() return type Date: Thu, 26 May 2022 15:29:52 -0400 Message-Id: <1653593392-1932-7-git-send-email-alec.r.brown@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1653593392-1932-1-git-send-email-alec.r.brown@oracle.com> References: <1653593392-1932-1-git-send-email-alec.r.brown@oracle.com> X-Proofpoint-GUID: FwLD6S-xhqACq-Ous7_edpiOKA8J9b5l X-Proofpoint-ORIG-GUID: FwLD6S-xhqACq-Ous7_edpiOKA8J9b5l Received-SPF: pass client-ip=205.220.165.32; envelope-from=alec.r.brown@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2022 19:30:58 -0000 In util/grub-module-verifierXX.c, the function get_shnum() returns the variable shnum, which is of the type Elf_Word. In the function, shnum can be obtained by the e_shnum member of an Elf_Ehdr or the sh_size member of an Elf_Shdr. The sh_size member can either be grub_uint32_t or grub_uint64_t, depending on the architecture, but Elf_Word is only grub_uint32_t. To account for when sh_size is grub_uint64_t, we can set shnum to have type Elf_Shnum and have get_shnum() return an Elf_Shnum. Signed-off-by: Alec Brown --- util/grub-module-verifierXX.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c index cf3ff0dfa..8e0cd91d9 100644 --- a/util/grub-module-verifierXX.c +++ b/util/grub-module-verifierXX.c @@ -18,6 +18,7 @@ # define Elf_Rel Elf32_Rel # define Elf_Word Elf32_Word # define Elf_Half Elf32_Half +# define Elf_Shnum Elf32_Shnum # define Elf_Section Elf32_Section # define ELF_R_SYM(val) ELF32_R_SYM(val) # define ELF_R_TYPE(val) ELF32_R_TYPE(val) @@ -36,6 +37,7 @@ # define Elf_Rel Elf64_Rel # define Elf_Word Elf64_Word # define Elf_Half Elf64_Half +# define Elf_Shnum Elf64_Shnum # define Elf_Section Elf64_Section # define ELF_R_SYM(val) ELF64_R_SYM(val) # define ELF_R_TYPE(val) ELF64_R_TYPE(val) @@ -141,11 +143,11 @@ get_shdr (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, Elf_Word in index * grub_target_to_host16 (e->e_shentsize)); } -static Elf_Word +static Elf_Shnum get_shnum (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) { Elf_Shdr *s; - Elf_Word shnum; + Elf_Shnum shnum; shnum = grub_target_to_host16 (e->e_shnum); if (shnum == SHN_UNDEF) @@ -153,12 +155,12 @@ get_shnum (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) s = get_shdr (arch, e, 0); shnum = grub_target_to_host (s->sh_size); if (shnum < SHN_LORESERVE) - grub_util_error ("Invalid number of section header table entries in sh_size: %d", shnum); + grub_util_error ("Invalid number of section header table entries in sh_size: %" PRIuGRUB_UINT64_T, (grub_uint64_t) shnum); } else { if (shnum >= SHN_LORESERVE) - grub_util_error ("Invalid number of section header table entries in e_shnum: %d", shnum); + grub_util_error ("Invalid number of section header table entries in e_shnum: %" PRIuGRUB_UINT64_T, (grub_uint64_t) shnum); } return shnum; -- 2.27.0