From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) by mx.groups.io with SMTP id smtpd.web12.1292.1617156991479806915 for ; Tue, 30 Mar 2021 19:16:31 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=xuldJLPO; spf=pass (domain: nuviainc.com, ip: 209.85.210.45, mailfrom: rebecca@nuviainc.com) Received: by mail-ot1-f45.google.com with SMTP id w31-20020a9d36220000b02901f2cbfc9743so17523132otb.7 for ; Tue, 30 Mar 2021 19:16:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nLsuJ/rhhBdH6fLn2nDMtWn7pGe4AWf87hZ0SBr73dw=; b=xuldJLPOZNyJUqU/Zd4PIU+pKKcGhm9nPXBKVD1nRaAVADjesvUDANZ1MRY49WUPxU JegP0nHNyxZ7EnGdboV5VlFk068L4f2LnWVtnlI7FPuYfIVly9TkT5rrNoJakpTMvZXr +oKZtX0iUBp23Uk2584ArKwev9oEXoUeNKRfXKyJgVyyx1+hkeudVG7X03dy6NnBXEAv /limMCWm87vnFMvpuXGYNCzuzkN3dL0KG8ycK/J2ZY9Zxu2JW8eB6X+Jcnp5Lcf3Hai1 uJhNv4Ak2NgBT3zwKba27SI/u9sJbwOR09f9z1JCG3EFXed9tyc+toOzNHtz4GCCuQjO jGpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nLsuJ/rhhBdH6fLn2nDMtWn7pGe4AWf87hZ0SBr73dw=; b=tbkuLw2A8ahmzPY2UrvBYhrVcPgBjRDKycBaPjkgOgOoqHu5LNPd32zkQeTpJ52Oa3 9LXYZz50T7OZzzwIEovW0DxCa4KU6Rm/e/oh2I3fm5w3zDETrjk6cJ0pnv/4VNyP0nC+ NDbXAQSYFCm5X1nxI9G5cF5zFkKCxwSSHZihH7/6xrhyEY3PaShHSvhBoiRiEld86XI1 Ia5sql2OiGdxZYdFNYy1pKP2hivEYIMZ4cBgLnuOC+NnKbPGxoriR62VDgKHLp0yIQ0Q HJC0AyJ0bTpatioAZoYG0brJZ9thn7EM21bmopvSr9T9PSHze0jVos+Uka8BKv7WwKGB qpLg== X-Gm-Message-State: AOAM530o9zrav7nuS0QwVG/qFCQ//zf1/woO5He+NmKslwTKdExs1+VC kQvECYbpVSFQjJoeTFD3bc9YkuIzRORe+fxioF3/qbCMYkhuJK2TgTbf2hBNGv6iZdLZyjC2FJk jo2zyzSwyWdpCFtifvXnHBGaab7ePEkLiHx7WP3365+p2gf+ByDyEvUB+FGROt/naWERaJQ== X-Google-Smtp-Source: ABdhPJy/33T6fx8L+Uj0szJE4uW/tIh4Dt/I5MuEe880jiYUiRlOCgM9h77p1evRCgJD6on2oaWRQw== X-Received: by 2002:a9d:921:: with SMTP id 30mr710339otp.49.1617156990609; Tue, 30 Mar 2021 19:16:30 -0700 (PDT) Return-Path: Received: from cube.nuviainc.com (c-174-52-16-57.hsd1.ut.comcast.net. [174.52.16.57]) by smtp.gmail.com with ESMTPSA id u11sm199996oif.10.2021.03.30.19.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 19:16:30 -0700 (PDT) From: "Rebecca Cran" To: devel@edk2.groups.io Cc: Rebecca Cran , Leif Lindholm , Ard Biesheuvel Subject: [PATCH 4/5] ArmPkg: Fix calculation of offset of chassis SKU Number in SmbiosMiscDxe Date: Tue, 30 Mar 2021 20:16:18 -0600 Message-Id: <20210331021619.19761-5-rebecca@nuviainc.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210331021619.19761-1-rebecca@nuviainc.com> References: <20210331021619.19761-1-rebecca@nuviainc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The calculation of the chassis SKU number field was being calculated incorrectly, forgetting that there's one element already present in the structure. Fix the calculation and improve code readability by introducing a SkuNumberField variable. Signed-off-by: Rebecca Cran --- ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type03/MiscChassisManufacturerFunction.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type03/MiscChassisManufacturerFunction.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type03/MiscChassisManufacturerFunction.c index 344343ed60a5..66e3e5327fc3 100644 --- a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type03/MiscChassisManufacturerFunction.c +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type03/MiscChassisManufacturerFunction.c @@ -39,6 +39,7 @@ SMBIOS_MISC_TABLE_FUNCTION(MiscChassisManufacturer) { CHAR8 *OptionalStrStart; CHAR8 *StrStart; + UINT8 *SkuNumberField; UINTN RecordLength; UINTN ManuStrLen; UINTN VerStrLen; @@ -117,10 +118,7 @@ SMBIOS_MISC_TABLE_FUNCTION(MiscChassisManufacturer) ChaNumStrLen = StrLen (ChassisSkuNumber); ContainedElementCount = InputData->ContainedElementCount; - - if (ContainedElementCount > 1) { - ExtendLength = (ContainedElementCount - 1) * sizeof (CONTAINED_ELEMENT); - } + ExtendLength = ContainedElementCount * sizeof (CONTAINED_ELEMENT); // // Two zeros following the last string. @@ -149,7 +147,11 @@ SMBIOS_MISC_TABLE_FUNCTION(MiscChassisManufacturer) (VOID)CopyMem (SmbiosRecord + 1, &ContainedElements, ExtendLength); //ChassisSkuNumber - *((UINT8 *)SmbiosRecord + sizeof (SMBIOS_TABLE_TYPE3) + ExtendLength) = 5; + SkuNumberField = (UINT8 *)SmbiosRecord + + sizeof (SMBIOS_TABLE_TYPE3) - + sizeof (CONTAINED_ELEMENT) + ExtendLength; + + *SkuNumberField = 5; OptionalStrStart = (CHAR8 *)((UINT8 *)SmbiosRecord + sizeof (SMBIOS_TABLE_TYPE3) + ExtendLength + 1); -- 2.26.2