From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=VSWc6KRZ; spf=pass (domain: arm.com, ip: 40.107.0.50, mailfrom: krzysztof.koch@arm.com) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (EUR02-AM5-obe.outbound.protection.outlook.com [40.107.0.50]) by groups.io with SMTP; Thu, 15 Aug 2019 06:11:52 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wD023htNTzHRA50fVWCFUxwiz2OUkkfk6Dc0jd03ToQ=; b=VSWc6KRZiA9DCYbPnotYh/128N4rCjgLK2aT2WZMX+SD47ssJj5l49gSB7OPnaHhqe++dT8kcULQfnUIES/20nrWE3zs8xkjSO4IbEOHHEyD5SpgH4YxEtMSt/1Ywk+XICus5hQI9BO1OYvoorIK7or/CjruvsaGCtdAO/4BRVo= Received: from VE1PR08CA0008.eurprd08.prod.outlook.com (2603:10a6:803:104::21) by DB6PR0802MB2600.eurprd08.prod.outlook.com (2603:10a6:4:a1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Thu, 15 Aug 2019 13:11:48 +0000 Received: from AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::209) by VE1PR08CA0008.outlook.office365.com (2603:10a6:803:104::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16 via Frontend Transport; Thu, 15 Aug 2019 13:11:48 +0000 Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT018.mail.protection.outlook.com (10.152.16.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16 via Frontend Transport; Thu, 15 Aug 2019 13:11:46 +0000 Received: ("Tessian outbound 220137ab7b0b:v26"); Thu, 15 Aug 2019 13:11:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6e6fe97b1905bdde X-CR-MTA-TID: 64aa7808 Received: from 32c175e99651.1 (cr-mta-lb-1.cr-mta-net [104.47.8.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8D130C8E-53A8-46D3-839A-DE07BEF2968E.1; Thu, 15 Aug 2019 13:11:39 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03lp2051.outbound.protection.outlook.com [104.47.8.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 32c175e99651.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Thu, 15 Aug 2019 13:11:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aG2U2Ij0ARCYwOrhtlNIaYqTz8qJZBj/Os6oJzm+lxlTSvFBQKMRmC6+Bzq3DMdfhdTK3IH5cIMOyGPUrd7SDImdcES58jI3qXUD3cYBRYRiteLpfMz4WHlEnbCg5fCpjDxb61QFMzwAURBNtNLte1b3Hc6/ePOftRBldqPs1DOP0A5A6U3QcLISZBvQMhcXn4QskLBrREGOD8sL/4YReZFUd5qpu4eH17Boeon2lBNre6ecS1SpmPp2JVlPrQlguo9vq2NddJrup4jW/vNiBwvKpOppJxmz7nV9BMyvf3JbNlBBR7BMBgHFKZ9zDyMsEb0npC5AjDE5F1xgIFbzRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wD023htNTzHRA50fVWCFUxwiz2OUkkfk6Dc0jd03ToQ=; b=kmlGim030pU4kMafGfO6JdYrsuP9A2J3SKlBSraZbLamSNCXoC7QKyZoSIEfQo3UcZ6P7GtX3M60uO03N4iUWL84C+IaCEKaGxUlzd7W5/Apn96uvl1gve/s0eJewMMlFAotLRLEVutFLyBeIj0eI75qv8xqSaoPjGzwWBHM/aEmKW4fuAIQgkHXftBkb1UP51FvUwsbwc0Y0/8JJW/Hllgb7da1vkBejSNR3vXmbO7VgFf9LxA105pwLvMaCuVWnniHhRLQKlIWQiM2Y9I8WygGEiiqy/C10E7408b8+7e8ELs9gsJwLZ4bZrZxYn8YaQbx/IidzFVhtEfHJWItjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=temperror action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wD023htNTzHRA50fVWCFUxwiz2OUkkfk6Dc0jd03ToQ=; b=VSWc6KRZiA9DCYbPnotYh/128N4rCjgLK2aT2WZMX+SD47ssJj5l49gSB7OPnaHhqe++dT8kcULQfnUIES/20nrWE3zs8xkjSO4IbEOHHEyD5SpgH4YxEtMSt/1Ywk+XICus5hQI9BO1OYvoorIK7or/CjruvsaGCtdAO/4BRVo= Received: from VI1PR08CA0133.eurprd08.prod.outlook.com (2603:10a6:800:d5::11) by DB8PR08MB4956.eurprd08.prod.outlook.com (2603:10a6:10:e0::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.18; Thu, 15 Aug 2019 13:11:37 +0000 Received: from DB5EUR03FT040.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::205) by VI1PR08CA0133.outlook.office365.com (2603:10a6:800:d5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2178.16 via Frontend Transport; Thu, 15 Aug 2019 13:11:37 +0000 Authentication-Results-Original: spf=temperror (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT040.mail.protection.outlook.com (10.152.20.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2178.16 via Frontend Transport; Thu, 15 Aug 2019 13:11:35 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Thu, 15 Aug 2019 13:11:35 +0000 Received: from E119924.Arm.com (10.1.199.124) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Thu, 15 Aug 2019 13:11:34 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [PATCH v1 04/11] ShellPkg: acpiview: SLIT: Validate global pointer before use Date: Thu, 15 Aug 2019 14:11:14 +0100 Message-ID: <20190815131121.52644-5-krzysztof.koch@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20190815131121.52644-1-krzysztof.koch@arm.com> References: <20190815131121.52644-1-krzysztof.koch@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;IPV:NLI;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(396003)(39860400002)(136003)(376002)(346002)(2980300002)(189003)(199004)(51416003)(446003)(86362001)(76176011)(63370400001)(305945005)(26005)(15650500001)(426003)(2351001)(7696005)(44832011)(186003)(5660300002)(486006)(50466002)(6916009)(1076003)(2906002)(336012)(53416004)(126002)(356004)(6666004)(48376002)(11346002)(2616005)(63350400001)(476003)(70206006)(81156014)(81166006)(50226002)(8676002)(54906003)(478600001)(16586007)(8936002)(4326008)(36756003)(70586007)(316002)(47776003)(53936002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB8PR08MB4956;H:nebula.arm.com;FPR:;SPF:TempError;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a394886b-1ed1-421a-2008-08d721822009 X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:DB8PR08MB4956; X-MS-TrafficTypeDiagnostic: DB8PR08MB4956:|DB6PR0802MB2600: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:5797;OLM:5797; X-Forefront-PRVS: 01304918F3 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: PPUdjQEMH2tsfcGO+A8VGDVxI+oppSFhYjhZ24erOpMtUDXK7XsK73ck7EqOZVuJH4WDaJOnLmdQ0rGINiscWIHHqe1RDwOxxhJweo36tgK3f6SQKkFEeoH5/J5M5tCj2G/ilGfbB1egm53mZPYMNvbjB7ZXnT7X3+PI9IPdZfI9fYAFa8VPAXMr3urj1aLcJsBip0ZRZcgsEf1v4ehfPT/yQ/RiafP8CBP5f/9P0iE4g59s3SDd0gVT7a48dkZPi3rxTRqjTZhCugfBT2fWMZ2GW4RMv3aJ6/K6eNGKMBnxzjB9ilaxqGMZtYy46jpFw7kVZH7cbnB5wqs4AWbjYWdUCzkuoB9VB5zDBQxZXztiJiQnEHb68o5rKaQrrhsmp5BSJxZJu1JzAp5tCI5cTTcVPh2Z+3RjCSUJAIHo3iE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB4956 Original-Authentication-Results: spf=temperror (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=temperror action=none header.from=arm.com; Return-Path: Krzysztof.Koch@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;IPV:CAL;SCL:-1;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(376002)(346002)(136003)(39860400002)(396003)(2980300002)(199004)(189003)(8936002)(81166006)(53416004)(81156014)(8676002)(36756003)(305945005)(2351001)(50226002)(2906002)(6666004)(4326008)(54906003)(6916009)(70586007)(70206006)(76130400001)(50466002)(1076003)(48376002)(51416003)(7696005)(22756006)(316002)(36906005)(16586007)(15650500001)(86362001)(76176011)(26826003)(446003)(486006)(26005)(478600001)(186003)(11346002)(126002)(476003)(2616005)(336012)(47776003)(426003)(44832011)(5660300002)(63350400001)(63370400001);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0802MB2600;H:64aa7808-outbound-1.mta.getcheckrecipient.com;FPR:;SPF:TempError;LANG:en;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;A:1;MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 914cf0f4-4bf0-4efb-49e8-08d7218219ce X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(710020)(711020)(4605104)(1401327)(2017052603328);SRVR:DB6PR0802MB2600; NoDisclaimer: True X-Forefront-PRVS: 01304918F3 X-Microsoft-Antispam-Message-Info: Pb0q9WAbEFn2dbDV9kCc5Ve7gbLIpBlx5STBHi4BHBydjjwXPH+HHBTldxbwBXwJjpxonjXalCHSuufP+az3sGbsP+Y5ChLZCLHMUD4E2JFg909Svnta94ozXMOG9LKHvHgn/oKMSYkIiEdUad6Rko0qrzV84AQ7CIdlWKtw4HuK3cz/Dtt98LZPJiqgkLP+l2eDvlRN5D09nei6/BxQHMIqNN2DkGyIusz2fSUnIiUhwe3jI25ywfrAraEGOQbc3nlv+dwX8jrLEewpeFTTDO0XWXNqCkVq3FHYvXu6zE1HeMFLVwFr4y+zyi/MauzWc0R1l6EbaIveuQ+Dx1UT1eYVaVfmMzVLmlb/lfBljcDjq055sVbuhxZfZd0LzqYAkkf8qm7RMEF7ks8Nsfj12u5wFeiYC5PcrUS643WWd4U= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2019 13:11:46.2407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a394886b-1ed1-421a-2008-08d721822009 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2600 Content-Type: text/plain Check if SlitSystemLocalityCount pointer has been successfully updated before it is used for further table parsing. Signed-off-by: Krzysztof Koch --- Notes: v1: - Test against NULL pointers [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c index ca2808db526b1bbb79aeb21ccfc0ae6c79b2dfd8..17e2166a09d8615b714e0c51d4d93d293fcdf601 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c @@ -1,7 +1,7 @@ /** @file SLIT table parser - Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. + Copyright (c) 2016 - 2019, ARM Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @par Reference(s): @@ -75,9 +75,21 @@ ParseAcpiSlit ( AcpiTableLength, PARSER_PARAMS (SlitParser) ); + + // Check if the values used to control the parsing logic have been + // successfully read. + if (SlitSystemLocalityCount == NULL) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient table length. AcpiTableLength = %d.\n", + AcpiTableLength + ); + return; + } + LocalityPtr = Ptr + Offset; - LocalityCount = *SlitSystemLocalityCount; + // We only print the Localities if the count is less than 16 // If the locality count is more than 16 then refer to the // raw data dump. -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'