From patchwork Thu Nov 29 12:31:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152397 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2320683ljp; Thu, 29 Nov 2018 04:31:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/VLtErGbwJe8F9nLvB56r289a9YLQDWkEsofCQYupHX/KOwqtOw2JSdpBad2jAUBJWW4t2J X-Received: by 2002:a62:1b50:: with SMTP id b77mr1239945pfb.36.1543494701733; Thu, 29 Nov 2018 04:31:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543494701; cv=none; d=google.com; s=arc-20160816; b=uinKVYCTgrkIW8F51jazVMCPy1E6x8c8+2Um1Dup88LTTQY+1O8N5QUwJZW47JBBtd NlU9N2PxM1MD79TZKXdbIk299uoIrslkV6OoS3L11gM0FrXvesiqxdDJXrwWT82kvfJm 8umaPlKIuigKYfpbEkdXXxIZ9krcSekFn64+Sq/RVmLHL4Ve6E/bcnbeiOqnKz1ff63q D0XAuZaQc1gOwx6oVV9g/K+tdn3/0bedxt15VD/YISDMhn9C4gYRAhHVsiBV6Yb+HRnk pRKoboTQQ4pQEs+MsryaU0z81lEUzuJn81hguLHqxVPZGRvQ2kmQ5hJwOf1n2VSQAh7V IHaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=UzxDD0LXvSpvAtnxzSwTcgewTmsGJQuOiVPVHB0S9Vw=; b=gtNlu1kY94HkTvR1oo7ZMQQT66Sm+ZeRTXLmZ8adk0FFyCZxerrKTRnsjQ8WlPIKS0 /Ak41WkxegdPCJ9wkLNQvR4oEEPNnA3/tQOmsQZPIbkquOpBc2JTqHqcc83M3jJ9f0jp t8rRhs3Ot5+w7Rgllnct/RLpOXYlBlqQ+a8HXC/e7fHhmU+Rr34YsfUYn7SslVvJ6Dvh OnUtEHOBMbhapwY3VFMZCb0xRIvErROSGKAn3LDEOP7Ql2pKF89vays2pdal0jOPqOq/ KjsnJWPTKKEbR+ZgQQCLDjW2egyY0jSSa8euq0vG6dgGCkuHTr1+EjkagAuTdPoxqk/5 6wAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gJXirWEm; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id ce19si2302428plb.13.2018.11.29.04.31.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 04:31:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gJXirWEm; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6DFFF211963CA; Thu, 29 Nov 2018 04:31:39 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::343; helo=mail-wm1-x343.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 84A1B211963CA for ; Thu, 29 Nov 2018 04:31:38 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id n133so2050096wmd.4 for ; Thu, 29 Nov 2018 04:31:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eeYJQFPL7MzVqX4e1vHb27YCry6UCE4KXVC7xKXyCKM=; b=gJXirWEmPv1Rz2B4JW8R3A0DkR/dCVaPm9+a+Gd5sIUihtBpha0a6f66I7KhmHtueH jepFXCZx47kUKXc3TkF3AtEBjKDDR5xt99PpBxtNWJxNHQbiBpHatfbNqMLS0IPhIuLj ypmkKOosBHb9Q4/Gkhs6MAxpGZ0loi7xjvQBs= 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=eeYJQFPL7MzVqX4e1vHb27YCry6UCE4KXVC7xKXyCKM=; b=rSlwUrd/2tYA6f3cDfVNx2FbBRE3BcC/KC2NOAm4GW7Il5hnRwLXIgapKUC9+QAYkH UQeZ7NhGCN+3rU0CwtECp/Ie26RcrVdbHfeYDfdQByE9YPD08xk8QxowEMWmB+r2YXF6 8liH98ShaYObIc0DcFHwuVaJosX4WQ/V4RIfXQsQuJXpwI9ZtaY2a/RDgiC6f/NK1ZeC TSeJMHn3gVDlvjSZ0iBk9NyPb+MD8m57Qum89dw7ydLd+vnO69gWhu72bN5yyzoKnWLB G8ftkoOsuI+4Zl4ITZDYb+MxZV0DzVlWgKkLuzgOi+RMPrZCkj3mN+W/k3sbDg8J1bgP qokA== X-Gm-Message-State: AA+aEWZPD3IwJCSJN3r5suTa6vKWBZL+B5OBuSHPMjQFuCpUc+zPsqU+ IFWH14kVAVVAK9W0aqsXncXKcSbCrMA= X-Received: by 2002:a1c:d74a:: with SMTP id o71mr1619550wmg.103.1543494695642; Thu, 29 Nov 2018 04:31:35 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:3580:6f80:40a7:5bdd]) by smtp.gmail.com with ESMTPSA id c7sm3089525wre.64.2018.11.29.04.31.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 04:31:34 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 29 Nov 2018 13:31:24 +0100 Message-Id: <20181129123129.25095-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181129123129.25095-1-ard.biesheuvel@linaro.org> References: <20181129123129.25095-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH 1/6] BaseTools/CommonLib: avoid using 'native' word size in IP address handling X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laszlo Ersek , Liming Gao Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In the context of the BaseTools, there is no such thing as a native word size, given that the same set of tools may be used to build a firmware image consisting of both 32-bit and 64-bit modules. So update StrToIpv4Address() and StrToIpv6Address() to use UINT64 types instead of UINTN types when parsing strings. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- BaseTools/Source/C/Common/CommonLib.c | 28 ++++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) -- 2.19.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/BaseTools/Source/C/Common/CommonLib.c b/BaseTools/Source/C/Common/CommonLib.c index 618aadac781a..bea6af0a45b1 100644 --- a/BaseTools/Source/C/Common/CommonLib.c +++ b/BaseTools/Source/C/Common/CommonLib.c @@ -1785,7 +1785,7 @@ StrToIpv4Address ( { RETURN_STATUS Status; UINTN AddressIndex; - UINTN Uintn; + UINTN Uint64; EFI_IPv4_ADDRESS LocalAddress; UINT8 LocalPrefixLength; CHAR16 *Pointer; @@ -1812,7 +1812,7 @@ StrToIpv4Address ( // // Get D or P. // - Status = StrDecimalToUintnS ((CONST CHAR16 *) Pointer, &Pointer, &Uintn); + Status = StrDecimalToUint64S ((CONST CHAR16 *) Pointer, &Pointer, &Uint64); if (RETURN_ERROR (Status)) { return RETURN_UNSUPPORTED; } @@ -1820,18 +1820,18 @@ StrToIpv4Address ( // // It's P. // - if (Uintn > 32) { + if (Uint64 > 32) { return RETURN_UNSUPPORTED; } - LocalPrefixLength = (UINT8) Uintn; + LocalPrefixLength = (UINT8) Uint64; } else { // // It's D. // - if (Uintn > MAX_UINT8) { + if (Uint64 > MAX_UINT8) { return RETURN_UNSUPPORTED; } - LocalAddress.Addr[AddressIndex] = (UINT8) Uintn; + LocalAddress.Addr[AddressIndex] = (UINT8) Uint64; AddressIndex++; } @@ -1888,7 +1888,7 @@ StrToIpv6Address ( { RETURN_STATUS Status; UINTN AddressIndex; - UINTN Uintn; + UINT64 Uint64; EFI_IPv6_ADDRESS LocalAddress; UINT8 LocalPrefixLength; CONST CHAR16 *Pointer; @@ -1969,7 +1969,7 @@ StrToIpv6Address ( // // Get X. // - Status = StrHexToUintnS (Pointer, &End, &Uintn); + Status = StrHexToUint64S (Pointer, &End, &Uint64); if (RETURN_ERROR (Status) || End - Pointer > 4) { // // Number of hexadecimal digit characters is no more than 4. @@ -1978,24 +1978,24 @@ StrToIpv6Address ( } Pointer = End; // - // Uintn won't exceed MAX_UINT16 if number of hexadecimal digit characters is no more than 4. + // Uint64 won't exceed MAX_UINT16 if number of hexadecimal digit characters is no more than 4. // ASSERT (AddressIndex + 1 < ARRAY_SIZE (Address->Addr)); - LocalAddress.Addr[AddressIndex] = (UINT8) ((UINT16) Uintn >> 8); - LocalAddress.Addr[AddressIndex + 1] = (UINT8) Uintn; + LocalAddress.Addr[AddressIndex] = (UINT8) ((UINT16) Uint64 >> 8); + LocalAddress.Addr[AddressIndex + 1] = (UINT8) Uint64; AddressIndex += 2; } else { // // Get P, then exit the loop. // - Status = StrDecimalToUintnS (Pointer, &End, &Uintn); - if (RETURN_ERROR (Status) || End == Pointer || Uintn > 128) { + Status = StrDecimalToUint64S (Pointer, &End, &Uint64); + if (RETURN_ERROR (Status) || End == Pointer || Uint64 > 128) { // // Prefix length should not exceed 128. // return RETURN_UNSUPPORTED; } - LocalPrefixLength = (UINT8) Uintn; + LocalPrefixLength = (UINT8) Uint64; Pointer = End; break; } From patchwork Thu Nov 29 12:31:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152398 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2320730ljp; Thu, 29 Nov 2018 04:31:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/VY1d8z2hmnzovd68kjPs9AZG01wKvG8I0ZGkY4TY2kXt0zqDg6MowxTl1J3bVoI+7cgVds X-Received: by 2002:a17:902:f44:: with SMTP id 62mr1322656ply.38.1543494704553; Thu, 29 Nov 2018 04:31:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543494704; cv=none; d=google.com; s=arc-20160816; b=xN/BcBNlSWMQnDq0JDRLEpvWpQXAoT3iVnE4DpOOSQegxWsHDG+XuS5jJTk2GuUPwb Bejj05a2LQN76tYDOSChzAC85o5IR2nSHZ/ImbLETrevNuW3DnSBts3BksS6f4yAcrpO MV7f3qiiwcG4KUq3tDWP0gNwBI+Z7JJQzoIh/MN34q/UtmIz4wA1JKhZPP+ENUpvop1R 8NiH6EoRz9R5wikZ2NYdEUrKsnoR0aLmgkFlYPD1H1RXXIbPaggwAXSbN7S0STz3N+tk w7sjngAfavxcqCCG+Q7U+ot3pL5zMlKOy08bFJ0tFVzZg6qyvmV0QCNZThwGiXoIpXKz cpOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=u8tPd7jv9G37Cu3Y0YapLZJEBIjdRdutguF+qilXbiY=; b=F32rBL1XYbK0tXRoIV4JFfc4FLdUwXOpJDvXaFCqVRA9DkwcWQp0LwkMeHhjDP15RO Bn0ac2EUkG7OJKoflotiTascpe6zYDWsUoqKdcqG5+fsPbXIJfjXQ4gt+G7REdcHX7r8 sgLbMSzvJnlBn+Y8+l99xp6io3eBOD09dDULxhZa9SqYWYI5M+r5HlNZ3ZTsePCmflWR fmfaiIFyk0C79jfhlBUkVpo/u1FSsCLTUE5S1xyuqgkp9NYfvdlzE2uzqdVj+Cg6zXvx sGHEgUWHKrZ46o72J6GymP0ezHPZwfWeB1tK/+NLjxStHeK6Uf4Zo/ifba2QQ0CiJwH/ IMMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YawALtlw; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id z15si1934962pgi.304.2018.11.29.04.31.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 04:31:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YawALtlw; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9F0EE211963F2; Thu, 29 Nov 2018 04:31:41 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::344; helo=mail-wm1-x344.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 95D2D21B02822 for ; Thu, 29 Nov 2018 04:31:38 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id g67so2052634wmd.2 for ; Thu, 29 Nov 2018 04:31:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SBt8rSHiUuncO+fe24SMlG0ee6qdCagt6QnFlvwTqdo=; b=YawALtlwWj1V8dAhMVlCpQXyxQGpUOr2Oet1xLdn6juApLx7dgjM6NUIH/vVS4nxWZ oPpiNBjEziPaO5KYcQ6129JvQxs1zC/FCLpKGeKia4g8ICsIumgAyRnlaLppV2BK5E+J TKcm/fJeJbWBbBhPFvAy7JQQ6Fm6BTZftERJ8= 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=SBt8rSHiUuncO+fe24SMlG0ee6qdCagt6QnFlvwTqdo=; b=jgPvRJjKYi8ZdMKqhQjMoZqYC4pb+y8s44/aYLE7JvRr+MuN9scy8m9DQ6xlzIm0AG 9+4DE3PWz6vaYpUP3frWOSq4EGRzGAXLDt8xhVyc2dkXVEZq0UwZ5ZZvJTzNkfOvcGAh 7TMEMxjxJ3auZfv4bL8BEq6pRSKsqH7N263F12bfCMh11KHB6HnvFqs9q6P8ct/mbAjH UsqgwRJNItbTxcDW/cV83boGkpe0DTxrx2KphtpA9gFrkBwhfMUVIWvVPJvAJdQykJKE EpDt5HKOjBVNjY+/6c/id3Zd3XGU0DUD+DDY08zovbUjG7L83oKhZbdIdRwbq4fp31hf DbVg== X-Gm-Message-State: AA+aEWaM9KpwuMw7Fa/gklISr0htxSxDnIfcs8jp1F9jJi4CfZuvp1ah uPcYIvaPa9fFkxui1iFzsGQcylKPwqU= X-Received: by 2002:a1c:5604:: with SMTP id k4mr881970wmb.107.1543494696821; Thu, 29 Nov 2018 04:31:36 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:3580:6f80:40a7:5bdd]) by smtp.gmail.com with ESMTPSA id c7sm3089525wre.64.2018.11.29.04.31.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 04:31:36 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 29 Nov 2018 13:31:25 +0100 Message-Id: <20181129123129.25095-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181129123129.25095-1-ard.biesheuvel@linaro.org> References: <20181129123129.25095-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH 2/6] BaseTools/CommonLib: use explicit 64-bit type in Strtoi() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laszlo Ersek , Liming Gao Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Don't use the native word size string to number parsing routines, but instead, use the 64-bit one and cast to UINTN. Currently, the only user is in Source/C/DevicePath/DevicePathFromText.c which takes care to use Strtoi64 () unless it assumes the value fits in 32-bit, so this change is a no-op even on 32-bit build hosts. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- BaseTools/Source/C/Common/CommonLib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.19.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Jaben Carsey diff --git a/BaseTools/Source/C/Common/CommonLib.c b/BaseTools/Source/C/Common/CommonLib.c index bea6af0a45b1..c5e32b1292e0 100644 --- a/BaseTools/Source/C/Common/CommonLib.c +++ b/BaseTools/Source/C/Common/CommonLib.c @@ -2252,9 +2252,9 @@ Strtoi ( ) { if (IsHexStr (Str)) { - return StrHexToUintn (Str); + return (UINTN)StrHexToUint64 (Str); } else { - return StrDecimalToUintn (Str); + return (UINTN)StrDecimalToUint64 (Str); } } From patchwork Thu Nov 29 12:31:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152399 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2320787ljp; Thu, 29 Nov 2018 04:31:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/XG22oPBI1v0u8ExbZX4hVXoxM1oNfC8oO/f6+wCsXzNdOL262YGDo/9X+WT4Yq37aP0D/t X-Received: by 2002:a63:4c04:: with SMTP id z4mr1106930pga.312.1543494707564; Thu, 29 Nov 2018 04:31:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543494707; cv=none; d=google.com; s=arc-20160816; b=EnS7KZwQFTzoDVLyOnRDbZFxtVm8xWUmfkOKSIDqTuXrDWKBE0I8+9j+77wyxIpN5v ccr38ri8bgLN4CSr6KrP1McDqOEqQDWX4ZxvG5Pkyipbo0fO8wK8d+gJmmh+k3uMN+BD 7rP0FBLznu/dPOmPyQ/zUOTYVpB+Tvjr2+otYwlU/gwfAExE8tutLlQJoQp6UvudGLF4 Ehth3brdT42Q+vRQeQJSh0PQUXBvDDGg/tLAqml2cXV41MvuLtmRjkQmuUA5AIK+h0sb ss+PtLAKe1Iu65pNvk5iJYtEh5rgSdXQvTCSPG4fGIuQayXKbtUd7iz0ilmfBwqw2ANx GUmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=wcdnZWEQcVdfgodxcvp6F0QOQdsdSFpdrqOLz1XUk0o=; b=xMOuf94en9l6anAppAFtBkMLRGhkaOhTK83Y7s9XYYbDC0AzCOT2Ihd+RNB0Fm8M+0 A2ft/I5ZJHCreSbI1B/vY96RvIwKAE2mwnnIxckXyQiHvOtpcayx/YYQnJML8/Vqrk2Q HQi/6HwH0+wv+Or1fW3YDw/QI8HCGs/0Ag7haFogdlomtgkJbQhUoX3108O0ZOUAJHJo 9ZoEiId+fpyjxygAme1yK1CGi/hdwH3LeuLmNgHlK8bnCryWFjRwyPpbuO5sQdwx7Twq wdbR2SQPWo9x43Gg/AC7QQg7ZhM1Mmzzyb8W1CAaRSmBZKXBu+VC0DUAESC/LnA/Ewh4 b+Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZSmMipF0; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id s36si2061427pld.46.2018.11.29.04.31.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 04:31:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZSmMipF0; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D3ECD21BADAB9; Thu, 29 Nov 2018 04:31:41 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::341; helo=mail-wm1-x341.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B36BD21BADAB9 for ; Thu, 29 Nov 2018 04:31:39 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id y1so2066747wmi.3 for ; Thu, 29 Nov 2018 04:31:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c4vWTRxQlB5zBWAMIVBgKE8txScPd41TLF7KfR0J2Qc=; b=ZSmMipF03jZjNf0w335VaYej3wqAdi5PjoEqv72FPoezAqJ3Dx8crFB+cKXTyajD+P YQyTFhONvHazn8zM+ZUuyHJywJlR3OhWPpQTynJ94sfMOXkMUI/ACfAF8znXg5Tzovkf 7Gun9C2v6uSOhfMVpH+NQ+ijAenjJSRXnnqSg= 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=c4vWTRxQlB5zBWAMIVBgKE8txScPd41TLF7KfR0J2Qc=; b=fvsjKzNgkOGaY6ma5n7nXsi7cvvjW7pWepV1/zjnvxCXUM7EV2qzzMHZ0OMbEU90qL C5oot4aDEK9G8y5QWp/B5OX1pNphN0/6GqMFowxplp0ejaY7u+hJ93D0o6vMc8hhgPGX TkwMLtfdxVFEelVsIVyXEpbHQ3+Yz3q1pL18LOEGYsp/jEKR0CZyz7p2yA0r3H5E9FbB BQHwuuFcj5aP/7y5/WcVjflEKcYQaPAfpGWmnJt8/I9/yvtJiKazay3NzZyXUToHrV/Q s39xljeI78OFHYAKJXNHoI6xEEYkrvFuY1w4/M3PAF2hZvYvRTJiyowIBcR9Gy77FUBb sH0g== X-Gm-Message-State: AA+aEWYT1mujgCEkAjGkV6K38kgIHjS1qz7LCOdP4uQxDaXkxg0ZKIrP Tb+1773GdU+y9RuFcffy8SzQZBvv/Qk= X-Received: by 2002:a1c:9183:: with SMTP id t125mr1521404wmd.79.1543494697943; Thu, 29 Nov 2018 04:31:37 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:3580:6f80:40a7:5bdd]) by smtp.gmail.com with ESMTPSA id c7sm3089525wre.64.2018.11.29.04.31.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 04:31:37 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 29 Nov 2018 13:31:26 +0100 Message-Id: <20181129123129.25095-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181129123129.25095-1-ard.biesheuvel@linaro.org> References: <20181129123129.25095-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH 3/6] BaseTools/DevicePath: use explicit 64-bit number parsing routines X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laszlo Ersek , Liming Gao Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Replace invocations of StrHexToUintn() with StrHexToUint64(), so that we can drop the former. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- BaseTools/Source/C/DevicePath/DevicePathFromText.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.19.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Jaben Carsey diff --git a/BaseTools/Source/C/DevicePath/DevicePathFromText.c b/BaseTools/Source/C/DevicePath/DevicePathFromText.c index 555efa1acdde..6151926af9aa 100644 --- a/BaseTools/Source/C/DevicePath/DevicePathFromText.c +++ b/BaseTools/Source/C/DevicePath/DevicePathFromText.c @@ -520,7 +520,7 @@ EisaIdFromText ( return (((Text[0] - 'A' + 1) & 0x1f) << 10) + (((Text[1] - 'A' + 1) & 0x1f) << 5) + (((Text[2] - 'A' + 1) & 0x1f) << 0) - + (UINT32) (StrHexToUintn (&Text[3]) << 16) + + (UINT32) (StrHexToUint64 (&Text[3]) << 16) ; } @@ -1506,7 +1506,7 @@ DevPathFromTextNVMe ( Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8); while (Index-- != 0) { - Uuid[Index] = (UINT8) StrHexToUintn (SplitStr (&NamespaceUuidStr, L'-')); + Uuid[Index] = (UINT8) StrHexToUint64 (SplitStr (&NamespaceUuidStr, L'-')); } return (EFI_DEVICE_PATH_PROTOCOL *) Nvme; From patchwork Thu Nov 29 12:31:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152400 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2320838ljp; Thu, 29 Nov 2018 04:31:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/V1g8vRd1N2W38UnSY2WkARV6QBI1RsWfR+8LHOufKHPYKz3iaXtrD0jK4JotEc/pZADSj9 X-Received: by 2002:a63:4815:: with SMTP id v21mr1073951pga.308.1543494710818; Thu, 29 Nov 2018 04:31:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543494710; cv=none; d=google.com; s=arc-20160816; b=o+fJhUr1fQ9IMpZHpe49qLn/YDRCSPzoVWmRrXtBzy8rqP6RJ79WU5yfn+usrl3aQz rtIGBY1F0bzzEcSl5WIRXYr8/03eV2JkbuKAeUbhxfqESmBlG7YhtvAcb4ZOJ2G+ZAnP OXPRX4cpn3CPoQmCTKtJM4EBBaecuUSbWBdpI0xOyejQn6OrribU/xBedw0vgtH7TZe8 qUv9jyYE7Vo5m/c4OD0xCPYlzNUFKGvzRo4QB5YTaPeoKosq9s6aHnqqPQhnhV85nedk 9El3SCqp+ngAJWKCA95fKr1/SDRSH8/AlIhCHaFkP8jg2n4ZRytSO8rCEtw5NdzF/SqG 5V9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=BzEZoLzLpOVzafj6WUTGx+Eps5GdiVLCms4ydUlbF1Q=; b=rWFvjdPe5GZFvkz1/z7QJjwtImRkOjITgfh0LhTS/evThqL6Dnn9LJ/LJTMb914nom yYSBx1eszCNp1RBAHpMl9sMQiG1o18G2svqnWmlnfYtq0bRHh4H8vhX92l1Ge14pMlSs w80RSYWVQ5svL5UA32fLcRvmuohLAcJoRqD1Onjzs27sguzdTIm544In8mA9M5N+mX7H Os21mEnf+WHqmGK2c3WxkfkCcSrrEn2b5PijTcpdaN5RAD4G+9S1QjBrgyXs+yB4NbFt PqaUZ2NTArBffvhgFFc+IJpkh4sIecQaenyGJ7X/xf2GPS2+sfVsKmaUJ7vlQ+TNMV8H 7POQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aZCrAgnT; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id x8si2008859plo.259.2018.11.29.04.31.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 04:31:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aZCrAgnT; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0F4A1211963F6; Thu, 29 Nov 2018 04:31:44 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::442; helo=mail-wr1-x442.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4C394211963F0 for ; Thu, 29 Nov 2018 04:31:41 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id l9so1700612wrt.13 for ; Thu, 29 Nov 2018 04:31:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S+UbueAnN6mRAjftIfHNuxoTU6LNQJLEReQTkpWTQkQ=; b=aZCrAgnThVZkyB9YCuuWxGjzF1gxrj2FS+LF8m/6WQ10RnSYbebQiWnDPADv06hG0M LBulXzCgV79jVt/ll+mNlsAkXcE9YPmAEoJDKEXNv+YPL/OSILy4/BJjO1fUKbvH4XYw NFt4fBbOMA6zvutmqsMIJFrIJ0sYMVgzaECdY= 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=S+UbueAnN6mRAjftIfHNuxoTU6LNQJLEReQTkpWTQkQ=; b=luiAdNp/cSz0UoSY3ms3fdQrAog9tclzBqeZdUB4wU1Sj9z7QFTcdPOE4IfENFxEjY iopumO+I9dCILDxHbwVcMKLlh5P1xiIEhhF9h3KT3aF44BlDDCcsDYTR+A3m2M8ZRQWr AzIxsnu0oDYWQ9s+7KmqFfslnXc2yIGlLscKSlXKYTgEV44+Mjz/SVDZCK4T3yHWa6g+ JEJThwWicYlrF9sBdiCmSE3ayi4b0E0+StJpthiNYbreR4p4tNqkTcz4v+Np9dUA5X7Q Ia5SLiEjpgqJc3pz0MXK9iILKrX0fPq/pBZ4C/XAacQKnD/cB2Y73C6m7/C91bCQqYHE HBZA== X-Gm-Message-State: AA+aEWbEYzcPvnGKPtVlJPrSUQlYEkOnbfhM1XyvKWyZbJrKOdZQukSm YqyBTMX5CVWXJhOZOxeivXFeSvajPx8= X-Received: by 2002:a5d:628a:: with SMTP id k10mr1223553wru.254.1543494699073; Thu, 29 Nov 2018 04:31:39 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:3580:6f80:40a7:5bdd]) by smtp.gmail.com with ESMTPSA id c7sm3089525wre.64.2018.11.29.04.31.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 04:31:38 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 29 Nov 2018 13:31:27 +0100 Message-Id: <20181129123129.25095-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181129123129.25095-1-ard.biesheuvel@linaro.org> References: <20181129123129.25095-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH 4/6] BaseTools/DevicePath: use MAX_UINT16 as default device path max size X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laszlo Ersek , Liming Gao Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Replace the default size limit of IsDevicePathValid() with a value that does not depend on the native word size of the build host. 64 KB seems sufficient as the upper bound of a device path handled by UEFI. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- BaseTools/Source/C/DevicePath/DevicePathUtilities.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.19.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Jaben Carsey diff --git a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c b/BaseTools/Source/C/DevicePath/DevicePathUtilities.c index d4ec2742b7c8..ba7f83e53070 100644 --- a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c +++ b/BaseTools/Source/C/DevicePath/DevicePathUtilities.c @@ -62,7 +62,7 @@ IsDevicePathValid ( ASSERT (DevicePath != NULL); if (MaxSize == 0) { - MaxSize = MAX_UINTN; + MaxSize = MAX_UINT16; } // @@ -78,7 +78,7 @@ IsDevicePathValid ( return FALSE; } - if (NodeLength > MAX_UINTN - Size) { + if (NodeLength > MAX_UINT16 - Size) { return FALSE; } Size += NodeLength; From patchwork Thu Nov 29 12:31:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152401 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2320899ljp; Thu, 29 Nov 2018 04:31:54 -0800 (PST) X-Google-Smtp-Source: AFSGD/XeV4AFUFsx8A0383IUrtPrzUCbnwRFqEsV93b1CVXCZQgEbsd/nhSQuyyM1BdYMR8KK2LV X-Received: by 2002:a17:902:1103:: with SMTP id d3-v6mr1213673pla.249.1543494714170; Thu, 29 Nov 2018 04:31:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543494714; cv=none; d=google.com; s=arc-20160816; b=OnJXw3KxnSKsKLQAp656smnzBWE7Gk70yURfABqtb7Y09HFBZQFv2xgqX8fmYukrZU 26LAGO3maOUvZCXcpx+pP/3XnwYmvg+RgwGeFR9zbWIk4MUVh4W2cMV2UZpH4ZQg7Kvs hI49PhJ0EjkYPOQqgroADMPAcNki532i0I42BXMilKsHa6bTbIq2q5C0vX0X3ikbJL+g ibWd5UbiU1+JUMP3SZ/NpQkiAVic4nSy9+H3/xux4Jir4TbzW0iaMs6fal769vBDeILr Ci3aOP2xDg1AA9JVhX/StymAjTNGDY4qR4XDB/lGw2iQMAueGa1saVIF6M0wYPOMR5bh SUAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=XqtaR148T0j7ovL1xEIy9f9TlDem7yHG6M6extyLchM=; b=eSi0tpj/tggZZwGE9tRCVwLJT8DNaf7pQtl3AMId6wVHUW8DDswPWIOBQdKOrHgjV5 hqC5N6usH0+FjB1i3DRgxhGOwwz0EqEunIBVEE9qN+m0e7Ngts+qUJ/fGk9AgSxo5Dje gUnsOdgRkKhl898hOI2reYNPnYqru04PawTOP2dNU3WRuiFUiSgr5QYuSuFhvLXlgWcm Op3gInCa0HBdxp0qS2snJ2jq94R1lt106XpkOkqgVPNXOYbWzkOwMly7N9KcuCWnnWPe +6AzfEfPGMerRaJSYIZayMFwVAwNIMqZUxxR4Rj/BIORviogkuTiJeS5OtaSZ6tBfy/N 0CNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cvoRufdt; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id y12si1906307pgf.527.2018.11.29.04.31.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 04:31:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cvoRufdt; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3A3AA211963F1; Thu, 29 Nov 2018 04:31:44 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::430; helo=mail-wr1-x430.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 284E421CAD998 for ; Thu, 29 Nov 2018 04:31:42 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id v6so1697316wrr.12 for ; Thu, 29 Nov 2018 04:31:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mvUqSYk9dMxqvoHZt00Kgxsp+J1v4r3C9KgflUyN1nA=; b=cvoRufdt5Wx06+BUD3tI8Ekvy2sdglRmq7sKByASMSWuqHrTEi5Dba8ANpn0tGMplg g8vYOs70XfwOCNicEHfs/6fIH31HEbEO5Bd3yrWk2q/NoVZ6bgZPWyzZrI4djhDrnUCe ZPI6D8qvJyQ9lsPQ4Xk8ioXk6BKevbRu3rdfo= 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=mvUqSYk9dMxqvoHZt00Kgxsp+J1v4r3C9KgflUyN1nA=; b=Wnp/8lBpKaA3Csz5/EYOPr6nYOG28fQgPdnje+OjmQWqMrC2kgR3dh8DH0S/Hj+WyD p2xH5baLDldvg9pDMX9t1l6yak8o/iVfzkab4OEdPWHkm/7qe751Qy8iFCqb6PXMf5S1 C9KWs7jVgOoVTava9PlxuwhjlNI600krfB636fX+7hvj17Vc6gqOldDVyOA+H0GMMvtH AeAiPwP7aBKQbIXw1tf3HF250MuJYAjSYZ/MbgxtDUn91v96bfWaR8FJrAiR1/XQkkZa Z2uJuj72tlMBq5/4sV3ziNdQwve65k+f5xO+zPkWA0tdGuIbgdOBajlm1WOEEUj8qN3V eRbQ== X-Gm-Message-State: AA+aEWaXPdjFRdE/6kD52O+i8kHBk+I553yW57TFZ52d+NXKeKhOi1aW LpI6w3iM6iSg2kheC5aUwQ0Hzj8+ZGw= X-Received: by 2002:adf:80a9:: with SMTP id 38mr1178217wrl.137.1543494700308; Thu, 29 Nov 2018 04:31:40 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:3580:6f80:40a7:5bdd]) by smtp.gmail.com with ESMTPSA id c7sm3089525wre.64.2018.11.29.04.31.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 04:31:39 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 29 Nov 2018 13:31:28 +0100 Message-Id: <20181129123129.25095-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181129123129.25095-1-ard.biesheuvel@linaro.org> References: <20181129123129.25095-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH 5/6] BaseTools/CommonLib: get rid of 'native' type string parsing routines X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laszlo Ersek , Liming Gao Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Parsing a string into an integer variable of the native word size is not defined for the BaseTools, since the same tools may be used to build firmware for different targets with different native word sizes. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- BaseTools/Source/C/Common/CommonLib.h | 24 --- BaseTools/Source/C/Common/CommonLib.c | 174 +------------------- 2 files changed, 5 insertions(+), 193 deletions(-) -- 2.19.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/BaseTools/Source/C/Common/CommonLib.h b/BaseTools/Source/C/Common/CommonLib.h index fa10fac4682a..6930d9227b87 100644 --- a/BaseTools/Source/C/Common/CommonLib.h +++ b/BaseTools/Source/C/Common/CommonLib.h @@ -250,16 +250,6 @@ StrSize ( CONST CHAR16 *String ); -UINTN -StrHexToUintn ( - CONST CHAR16 *String - ); - -UINTN -StrDecimalToUintn ( - CONST CHAR16 *String - ); - UINT64 StrHexToUint64 ( CONST CHAR16 *String @@ -277,13 +267,6 @@ StrHexToUint64S ( UINT64 *Data ); -RETURN_STATUS -StrHexToUintnS ( - CONST CHAR16 *String, - CHAR16 **EndPointer, OPTIONAL - UINTN *Data - ); - RETURN_STATUS StrDecimalToUint64S ( CONST CHAR16 *String, @@ -291,13 +274,6 @@ StrDecimalToUint64S ( UINT64 *Data ); -RETURN_STATUS -StrDecimalToUintnS ( - CONST CHAR16 *String, - CHAR16 **EndPointer, OPTIONAL - UINTN *Data - ); - VOID * ReallocatePool ( UINTN OldSize, diff --git a/BaseTools/Source/C/Common/CommonLib.c b/BaseTools/Source/C/Common/CommonLib.c index c5e32b1292e0..9142a9a7eda3 100644 --- a/BaseTools/Source/C/Common/CommonLib.c +++ b/BaseTools/Source/C/Common/CommonLib.c @@ -882,72 +882,6 @@ InternalSafeStringNoStrOverlap ( return !InternalSafeStringIsOverlap (Str1, Size1 * sizeof(CHAR16), Str2, Size2 * sizeof(CHAR16)); } -RETURN_STATUS -StrDecimalToUintnS ( - CONST CHAR16 *String, - CHAR16 **EndPointer, OPTIONAL - UINTN *Data - ) -{ - ASSERT (((UINTN) String & BIT0) == 0); - - // - // 1. Neither String nor Data shall be a null pointer. - // - SAFE_STRING_CONSTRAINT_CHECK ((String != NULL), RETURN_INVALID_PARAMETER); - SAFE_STRING_CONSTRAINT_CHECK ((Data != NULL), RETURN_INVALID_PARAMETER); - - // - // 2. The length of String shall not be greater than RSIZE_MAX. - // - if (RSIZE_MAX != 0) { - SAFE_STRING_CONSTRAINT_CHECK ((StrnLenS (String, RSIZE_MAX + 1) <= RSIZE_MAX), RETURN_INVALID_PARAMETER); - } - - if (EndPointer != NULL) { - *EndPointer = (CHAR16 *) String; - } - - // - // Ignore the pad spaces (space or tab) - // - while ((*String == L' ') || (*String == L'\t')) { - String++; - } - - // - // Ignore leading Zeros after the spaces - // - while (*String == L'0') { - String++; - } - - *Data = 0; - - while (InternalIsDecimalDigitCharacter (*String)) { - // - // If the number represented by String overflows according to the range - // defined by UINTN, then MAX_UINTN is stored in *Data and - // RETURN_UNSUPPORTED is returned. - // - if (*Data > ((MAX_UINTN - (*String - L'0')) / 10)) { - *Data = MAX_UINTN; - if (EndPointer != NULL) { - *EndPointer = (CHAR16 *) String; - } - return RETURN_UNSUPPORTED; - } - - *Data = *Data * 10 + (*String - L'0'); - String++; - } - - if (EndPointer != NULL) { - *EndPointer = (CHAR16 *) String; - } - return RETURN_SUCCESS; -} - /** Convert a Null-terminated Unicode decimal string to a value of type UINT64. @@ -1064,9 +998,9 @@ StrDecimalToUint64S ( /** Convert a Null-terminated Unicode hexadecimal string to a value of type - UINTN. + UINT64. - This function outputs a value of type UINTN by interpreting the contents of + This function outputs a value of type UINT64 by interpreting the contents of the Unicode string specified by String as a hexadecimal number. The format of the input Unicode string String is: @@ -1091,8 +1025,8 @@ StrDecimalToUint64S ( If String has no valid hexadecimal digits in the above format, then 0 is stored at the location pointed to by Data. - If the number represented by String exceeds the range defined by UINTN, then - MAX_UINTN is stored at the location pointed to by Data. + If the number represented by String exceeds the range defined by UINT64, then + MAX_UINT64 is stored at the location pointed to by Data. If EndPointer is not NULL, a pointer to the character that stopped the scan is stored at the location pointed to by EndPointer. If String has no valid @@ -1112,86 +1046,10 @@ StrDecimalToUint64S ( characters, not including the Null-terminator. @retval RETURN_UNSUPPORTED If the number represented by String exceeds - the range defined by UINTN. + the range defined by UINT64. **/ RETURN_STATUS -StrHexToUintnS ( - CONST CHAR16 *String, - CHAR16 **EndPointer, OPTIONAL - UINTN *Data - ) -{ - ASSERT (((UINTN) String & BIT0) == 0); - - // - // 1. Neither String nor Data shall be a null pointer. - // - SAFE_STRING_CONSTRAINT_CHECK ((String != NULL), RETURN_INVALID_PARAMETER); - SAFE_STRING_CONSTRAINT_CHECK ((Data != NULL), RETURN_INVALID_PARAMETER); - - // - // 2. The length of String shall not be greater than RSIZE_MAX. - // - if (RSIZE_MAX != 0) { - SAFE_STRING_CONSTRAINT_CHECK ((StrnLenS (String, RSIZE_MAX + 1) <= RSIZE_MAX), RETURN_INVALID_PARAMETER); - } - - if (EndPointer != NULL) { - *EndPointer = (CHAR16 *) String; - } - - // - // Ignore the pad spaces (space or tab) - // - while ((*String == L' ') || (*String == L'\t')) { - String++; - } - - // - // Ignore leading Zeros after the spaces - // - while (*String == L'0') { - String++; - } - - if (InternalCharToUpper (*String) == L'X') { - if (*(String - 1) != L'0') { - *Data = 0; - return RETURN_SUCCESS; - } - // - // Skip the 'X' - // - String++; - } - - *Data = 0; - - while (InternalIsHexaDecimalDigitCharacter (*String)) { - // - // If the number represented by String overflows according to the range - // defined by UINTN, then MAX_UINTN is stored in *Data and - // RETURN_UNSUPPORTED is returned. - // - if (*Data > ((MAX_UINTN - InternalHexCharToUintn (*String)) >> 4)) { - *Data = MAX_UINTN; - if (EndPointer != NULL) { - *EndPointer = (CHAR16 *) String; - } - return RETURN_UNSUPPORTED; - } - - *Data = (*Data << 4) + InternalHexCharToUintn (*String); - String++; - } - - if (EndPointer != NULL) { - *EndPointer = (CHAR16 *) String; - } - return RETURN_SUCCESS; -} -RETURN_STATUS StrHexToUint64S ( CONST CHAR16 *String, CHAR16 **EndPointer, OPTIONAL @@ -1291,28 +1149,6 @@ StrHexToUint64 ( return Result; } -UINTN -StrDecimalToUintn ( - CONST CHAR16 *String - ) -{ - UINTN Result; - - StrDecimalToUintnS (String, (CHAR16 **) NULL, &Result); - return Result; -} - -UINTN -StrHexToUintn ( - CONST CHAR16 *String - ) -{ - UINTN Result; - - StrHexToUintnS (String, (CHAR16 **) NULL, &Result); - return Result; -} - UINTN StrSize ( CONST CHAR16 *String From patchwork Thu Nov 29 12:31:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152402 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2320977ljp; Thu, 29 Nov 2018 04:31:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xr4ZXav0fENS85hd6FYpBpOmumh4ax9QLpc+44ut7bD0IBrHDWrAp9mJYf6yh8p8ME0BlL X-Received: by 2002:a65:5286:: with SMTP id y6mr1064381pgp.439.1543494717843; Thu, 29 Nov 2018 04:31:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543494717; cv=none; d=google.com; s=arc-20160816; b=Qvrh9uUuBDi38zDkYmYA+7pNEftr1coCLx1jPJZYtA5RBdVk60TF43F7IaYQ09/R9W ME6NngUc47Uo3ctmaytC2wKP5u+zuI/WWpvaJpNoVKrzTgo6i3znFmj0V4NylF0VQfP8 N/ciq7pWRxBQ4sB859GwaKxbQrdDu0x7wZi7OgDKkdjHIevIpo0h+9mKhobPNJAbOxdB Zy0ghnchGMn9fkJrq+wg/RVngDy39VUuP/zl3btMto/jmdbVpt1SAUASujwVYvAajYsZ k2WVQzfRaJiZ8iP7bzggwHRYRlInM3v4BILxjyuIXv5LCg7uhdwqu3RFzhkBtYDP/emH TerA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=PCDcHNSGa+RffS+bMp29Wzm8ei3I1zOsa1w+Qj7yCLY=; b=cirt2vrORXh4Wf5+mFoY3JcqRXBIW83cd3ff/LoYhSbn0UwsRHSokMWSC3OzEqaAXc Y45ztdsSM5YBb8LjQ74t8cqFvCWJxegLBbDcEjVWT9TJssYf6o19s4eyr9jtYAinXpwA ii02Ah9pW3yKmfAcFKHZqL59rAEe41p/NisZ/1P1cbp6lIiwscjvdcxhwSwmAPZ0+RI4 xS1lAE24URtvEWZYf84xdV0I1IKCNc3IgxEaZMD1LyK0D6mGd2610tJ5tKTI1QDoqwAY 1EwfamgB1FSRCJQ5vv0q2Ci26LNDDkTWmUjzthmeoiaGp82xPh02lJ4J8F3eLJRZPQft x4ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LK2YI2HH; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id i1si1893061pgr.569.2018.11.29.04.31.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 04:31:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LK2YI2HH; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 661D721CB74A4; Thu, 29 Nov 2018 04:31:44 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::343; helo=mail-wm1-x343.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 130E021CAD998 for ; Thu, 29 Nov 2018 04:31:43 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id y185so6279833wmd.1 for ; Thu, 29 Nov 2018 04:31:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ClfePa18eW3Fx9/J8Ef9Pe0k/dIDucAlfJouSV/8AB4=; b=LK2YI2HH6wxiP5Verdlums+/AyMiVh5FTGyhJOEj9SuEFWXRYZaifTDT9JnGWQY3Jd PRdzsi3Ufm66TFqeD591qz713VhJhNWmA8fk+LLPgu0FlJ61gwzSTvcsXCny0x15zdda ZVMjUZpm+nu+W74QTmr9n2SLvlBUbAjSG5+eA= 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=ClfePa18eW3Fx9/J8Ef9Pe0k/dIDucAlfJouSV/8AB4=; b=r4K0RnMNnjPGWagBj9J6XQr5ytjW4QHAMV6xDclPpH28Tll+WE+Fm6vaBFrM3yiRfr l9jAh9OldzPYX3etkW2dWOU4M5HTpQGQ1/TxfI8lcgazy11KqH8QXbLgFuTQLQFE/z0Q WciSwNDfFFvtUWatxYkvsPVnZm1wBuBlqIIKfp+1ZTNfcL2teuskun4A01/KSDLFDRkL Qu8570nFJEEdtOUpmJG8wg2l2CYuI0dYfxfZzVdTxSv+4GY/M6W503rQZzZ91Vq2jVfm UupbW6YFnHpWP3x5YqJ3xSR1YW2oVY/lxIU3lm40E+23HymSTkMIJvGyYbv/ydl137l8 xCgg== X-Gm-Message-State: AA+aEWYCONeQCQweoe81mD9GuUxYeeV8c1v0upYMjipt6Bp+cWifSL9D 1Zbzxdm6qHkOnLv2UZD03KPdkgPGpPs= X-Received: by 2002:a7b:c5d1:: with SMTP id n17mr1566167wmk.152.1543494701462; Thu, 29 Nov 2018 04:31:41 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:3580:6f80:40a7:5bdd]) by smtp.gmail.com with ESMTPSA id c7sm3089525wre.64.2018.11.29.04.31.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 04:31:40 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 29 Nov 2018 13:31:29 +0100 Message-Id: <20181129123129.25095-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181129123129.25095-1-ard.biesheuvel@linaro.org> References: <20181129123129.25095-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH 6/6] BaseTools/CommonLib: drop definition of MAX_UINTN X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laszlo Ersek , Liming Gao Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The maximum value that can be represented by the native word size of the *target* should be irrelevant when compiling tools that run on the build *host*. So drop the definition of MAX_UINTN, now that we no longer use it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- BaseTools/Source/C/Common/CommonLib.h | 1 - 1 file changed, 1 deletion(-) -- 2.19.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Jaben Carsey diff --git a/BaseTools/Source/C/Common/CommonLib.h b/BaseTools/Source/C/Common/CommonLib.h index 6930d9227b87..b1c6c00a3478 100644 --- a/BaseTools/Source/C/Common/CommonLib.h +++ b/BaseTools/Source/C/Common/CommonLib.h @@ -22,7 +22,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define MAX_LONG_FILE_PATH 500 -#define MAX_UINTN MAX_ADDRESS #define MAX_UINT64 ((UINT64)0xFFFFFFFFFFFFFFFFULL) #define MAX_UINT16 ((UINT16)0xFFFF) #define MAX_UINT8 ((UINT8)0xFF)