From patchwork Fri Nov 30 22:45:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152609 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4211845ljp; Fri, 30 Nov 2018 14:45:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/UVV8HhPRv28dFFPFRt/qMfZEpsxFWUJtaOCo+S0y8tfqt1xayLQKTKbG7rTvv3m5qXFfr/ X-Received: by 2002:aa7:8552:: with SMTP id y18mr7472864pfn.83.1543617948183; Fri, 30 Nov 2018 14:45:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543617948; cv=none; d=google.com; s=arc-20160816; b=Yuyj7HOb8jQl3Lagjhcxs+89yL1Ewzfzh/0uttUvAJxXOw0DxeANyxCzz3b/Ovte9t 2pFbiXB2YMZTl0xqJwUf8S4gU+CP1L8XXaZKYlazOCLslwtOipTTY2imWlxDVT+sSOzq vJ5hZFX5aGP08dUDUGCGjVzLPRK2BBPi9ehyHlJIc/ndJ9IB+dBeWBKH/yB+UVd6aGT1 szPk912fPlHlTKMMbLSAbWu8elfuuBW1D7DVCStBJS1nyPdW9DrXObhyh+Z4egRaRhHa hz1N06qbQcsIm8nBpTUzjhM9uXsFSqAnYEAQNxoyrMfv364ue+dCxzPOU8cRx1fWSYoJ fh8w== 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=A0Mhn5jzUiD4mP3RYZx4M4TFkKiqglfzyiKL5pMvkRY=; b=v7Mdila5OdyGHK5Zw4W2FPXPLci1rDTC70RRIe8lL3r2h2VsijEtgRJaAdXsYi4kKz kk3W8jdUwOUQ7uDGNaCA+IlAhWinjaGZ/6ow/v0uJ5WIMxZ8awZ7XWxi+amx+Ha9DinT XePvne1mo73SWnXA3DixbxnxaBUrA6HNU9OYmZ2IPWv6iGkL2j3BnD29YjJBkLbKsqev 8KGLWDlVdPR+F6syBw2dzQXe4nmbVlj9tgoGB/Yfu0GBAXXwtAwJK7yybyQWVBp4wFTe mf2bVLjlGugrYb7EXlOzD8QUigJRp4U3SD/xUxqx2MEwcgSK9NhE+Joeucvlt74ZtUxT IzGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Orblfly2; 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 f63si6064370pgc.473.2018.11.30.14.45.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:45:48 -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=Orblfly2; 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 6EC1B21BADAB9; Fri, 30 Nov 2018 14:45:46 -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 BDFD8211963D9 for ; Fri, 30 Nov 2018 14:45:44 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id y1so445349wmi.3 for ; Fri, 30 Nov 2018 14:45:44 -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=gJ6apygiqYrhZFv1h43rGB8h3gUD5pOIeKAE9HDRrAE=; b=Orblfly2LZftQFpLnEWQ3JZCPIESegC/BQq+Gz9DUSVrWZ91+b3rwpSuF6LTRrSnmf 5CBgVum6YrylG3eYEHlF7e/6Fz49ywv6/sbXydU/G8aJ1xmVxqIB9e1tw777vULo2TR6 lw/DnacrsTB+cOHbQ1U2L48DI5bC7VbLv0PKY= 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=gJ6apygiqYrhZFv1h43rGB8h3gUD5pOIeKAE9HDRrAE=; b=ZCre7XQRaWdiAYs4ooweqHQN6sq1npoD0y/qt3uYCeeSXsgLngHjBfat/pXb/qQya+ 7IiayeKBV7vNs0ltV/SrGdOLrOmKndMrzhUfc3XsbJEJB3xAdQvOhrLUYtGw3sTxe4gV 54T7u1NsyNFrMjx7j4RtwTLxjDoewmkwaf9SOeMyxtqNqOpCFEs0nN1nijJY9uEySzRc krigB5WYFrcejBqU9BqBx0BjBXB5bcMpSf1P4OezF8dGJOW0oDOgocfwtV6V8RIFCSgy 7I6n2+oqutwIJKZRVURVRPRYqtG570b+0KnilghyQnTrcqdlLtJ/S6uo9F6KCRV/I9C8 y1cA== X-Gm-Message-State: AA+aEWYfoWd0h7FLT2/dOxEcnxUBs71ix4B6M1MDFn2+Hw6g/DX3tWHW mNb+b//T9Shjyi9+5bFMFNCHQwHRPjk= X-Received: by 2002:a1c:bd82:: with SMTP id n124mr476151wmf.105.1543617942845; Fri, 30 Nov 2018 14:45:42 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:d895:e032:7b00:86cd]) by smtp.gmail.com with ESMTPSA id m6sm10561195wrv.24.2018.11.30.14.45.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:45:41 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 30 Nov 2018 23:45:32 +0100 Message-Id: <20181130224537.18936-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130224537.18936-1-ard.biesheuvel@linaro.org> References: <20181130224537.18936-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH v2 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: Liming Gao , Jaben Carsey , Laszlo Ersek 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 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laszlo Ersek diff --git a/BaseTools/Source/C/Common/CommonLib.c b/BaseTools/Source/C/Common/CommonLib.c index 618aadac781a..7c559bc3c222 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; + UINT64 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 Fri Nov 30 22:45:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152610 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4211895ljp; Fri, 30 Nov 2018 14:45:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vyon+r+NJdIMntR3izM6oRIC7P8pi3ViUSgrPFZCmC0zEcj75Ap2EG0DuowL9GwBnwxQxA X-Received: by 2002:a63:a611:: with SMTP id t17mr6223338pge.338.1543617951101; Fri, 30 Nov 2018 14:45:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543617951; cv=none; d=google.com; s=arc-20160816; b=uii8ARE84xSbZJFP8JKbHqt2C5Ma8bgugcq7l7IbwsAP5//IE+5sC6+ZISw4frf7n5 iLrUf+oDA3c/gjHh2WuNZNbLxdLS/GFEj/tDe5ZpLp9aBq9d+Ry0eQ6/rKNZA9iTyaR5 vEt9U53g6SF+2eJrCThD/HDrRjrlIkfu7UgyJhjC6jQbmoxXgxw5wr71jsuKyR0uNp8Y C2B8bhs4VfmX+tQJbFVkhPTSNh5XmnDDrl2FMPrGNJry3vmTV2xnCJ6bfdbV3MhVjWxE t4NeqQ1TN5id2bMLCxka46nSLUFlGCUdJ6Zk2h5khi0rfIm3MLWgz878M5mU2miv2SK1 unWA== 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=wAJtXstO94GDGYN3Y5vfr6RfqJzGwl9GO1EjJFfY5SU=; b=Mg5A5xiQgk3wZ/kNsaSXqJpoRJiU+U/aCf82Bs7valZO4R5gtlOUTpcShzeyh2T7dg w6g5haicjbqIKjm3ewkLbk8F7yKI07paAs/i4WKyUyabqlTRbFYSOKXvxJ7gY7Ss6qNa Y2eC7P4pYLUAv1gdiJDoITZgs3yG8LWWotNXjJY2PSqHcCQBdqIXBgJHmhu9xjr0Mxvh KPcAqguQUvny7TWOSOXAJNPnORihXb+nFdUwfAnFG2PhTEnRy+2kz4epqv3iQm5UxzD3 fxrQg5GsUBVGsfkBoSQoX1ReLnfbXC7xKuH149SyOyXwb1WT+OXomu2tq0Hm5q+HwN3s Gyeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iA9bGTxS; 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 m8si5894767pgd.555.2018.11.30.14.45.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:45:51 -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=iA9bGTxS; 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 A750221196812; Fri, 30 Nov 2018 14:45:48 -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 09D12211963EE for ; Fri, 30 Nov 2018 14:45:46 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id s14so452975wmh.1 for ; Fri, 30 Nov 2018 14:45:45 -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=MpSBFKlR4smrBKLvtNuyjJGH/qSXgZ34/9H4jX8KUMw=; b=iA9bGTxSWRNC1E0X8Hg8uFrC9Q344wLYwu8vyfLiJHUtc8/Mc+/eSWK9fnQfBdoo47 cGxh6Z0tAW2WPxvmUAPAGpVrPjKbriQWVW8DBMjp+IdjuOqp2ipivJuyZV9ep7JdUYd7 /YsMKu1L6hecP57dQLKmiO4rCNcHJ9krWVtFc= 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=MpSBFKlR4smrBKLvtNuyjJGH/qSXgZ34/9H4jX8KUMw=; b=pPxkEuH5Ru0p62MVu5YoYRftW2uGulOEgHKzdQyVSEMrysSFQa3T/7Rb0RB6/rPzaY nNvAhzWm1Quy2lbvYzhr2aHTDyWhwrxFfVxlULxyvrIU6pfmC6Z1n40Y99zg/a25ageo ovcQZkYfAzLgatdIpDg93P3CR7m279sXeSBnyLUi42JKGs/ry3pJ+nsY5A3DXTHDv1ub goXW/Q9TYFnfvTNNiDh5WPyu/Vx28D+X6yOWoyZbGkzBIK+VFW4b6hUHfPbT6/jsLyBO SetwPCJ7I8BrXaRVGc+IBoUO/K+VB7v4cUMAYyaE3KPmVUiGeq8i4/XJH11jK+W06dJr 7JKA== X-Gm-Message-State: AA+aEWaeQE1GiGmOXNEC2g9c4WmPvCZf+/HnuAXhSWJrMdtTK4KjETOd TQVh7xT1TMfp9LsmNVsWuz+Veoo/Se8= X-Received: by 2002:a1c:f605:: with SMTP id w5mr535985wmc.116.1543617944229; Fri, 30 Nov 2018 14:45:44 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:d895:e032:7b00:86cd]) by smtp.gmail.com with ESMTPSA id m6sm10561195wrv.24.2018.11.30.14.45.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:45:43 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 30 Nov 2018 23:45:33 +0100 Message-Id: <20181130224537.18936-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130224537.18936-1-ard.biesheuvel@linaro.org> References: <20181130224537.18936-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH v2 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: Liming Gao , Jaben Carsey , Laszlo Ersek 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 Reviewed-by: Jaben Carsey --- 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: Philippe Mathieu-Daudé Reviewed-by: Laszlo Ersek diff --git a/BaseTools/Source/C/Common/CommonLib.c b/BaseTools/Source/C/Common/CommonLib.c index 7c559bc3c222..4a28f635f3a8 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 Fri Nov 30 22:45:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152611 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4211931ljp; Fri, 30 Nov 2018 14:45:54 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vr+FzBF9S3QrEq82mGa+5aCCrdTw0ubGaKju0D6FE7JKUyO8NPJwvCt16iawwbpHvx6Jjn X-Received: by 2002:a63:6906:: with SMTP id e6mr6241443pgc.144.1543617954134; Fri, 30 Nov 2018 14:45:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543617954; cv=none; d=google.com; s=arc-20160816; b=UD8CzDX2hYmwX7GC8BZyOiQQHnU63+3LwhpXYBAqr8QoguzeeY5yHO018sfS91ke/q c3aPLXNylVShySnrgwimxcSYQlPbyz4w9D54o1zZcWWm6YH+CMbvPOGXOvWBkCGbE+Xr FAjUI0ajUkAod+9NdSEqaqHCpxhoXjxtmEv+/hjPGnh28ppC5DEUdDxMJDgtByOjup+J FjgWvzeDPsjnyZ13Q6oi+5TSUWej9CIfy3DRQFf2XN1vIQFHzgzC1vIKSCzS3EYpylwE 2194ekM7KvLndgo04hJJn98XPLXx3wVaaWBxU/kVZ+SMVp7NXA1PcQkcAudusb7YNvo6 XlhQ== 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=Q4+OBBoHogAeLXKaYFqkrPcuucXk2d5rrJ1jbGlSUjA=; b=JqyX388XJelE2rM+OCx9plr5MXLtQrmVlYEg02QAwq5TfpaRbRasvxp0eZ/I0dlvic dOpMWGJj+a9p5IkJM7ag6BRzOQSDgg/90KdeE9WTpWvtMTQpFy41dhp6uB+898v5uL63 DrztY3dKEWmtAeYQ6/8M74p4tSFAkNNhYmKJZDg/4jKBY08mN9gDc2vxNDPRdMpc0Uwc B+McGbNBYToQ4fDhYzH3S4UMc44CSDKOBJDJEFoUiyGn09EKYrWwx6HJWaQQv7cmXN22 rKGA0SxLkEUTeAOobv/+BED8Ll9naQf5u/PgfLc93wGXw4UhBiPKfpMPfijvQFwb+7FN hneA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Cg34hb8A; 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 c11si6007102pgh.18.2018.11.30.14.45.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:45:54 -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=Cg34hb8A; 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 E2EFF2119681D; Fri, 30 Nov 2018 14:45:48 -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 664EE21CAD998 for ; Fri, 30 Nov 2018 14:45:47 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id 125so460998wmh.0 for ; Fri, 30 Nov 2018 14:45:47 -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=IwxSJ7/hod9iyIsWB+JQOfXbHLHjyVfIZrsrzBqXkQ0=; b=Cg34hb8Ak7n7E5K9+nXsSVD45BVxdFXEjmQxxZREQOb1ny/N2r7o5fBNPCk0hsdIbh zvs8GBfVlZtFIbpQYEze2yOkRkrwEXbYzGUlDWmll5rziYooVGQGBjrmy9CK+B5LZUjb ZObja3ILebzVUyFx8BZQ1B5aVxpJZ2dF214xA= 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=IwxSJ7/hod9iyIsWB+JQOfXbHLHjyVfIZrsrzBqXkQ0=; b=qqv79G17QbeELLH46xhqTYKGAlhjIl4eRrMcpYSmhPklcHy0rtQvSYseN+JZo9OxaF 2K+N//AGj1WxFBKTPhqH63JFd4qWrW+gC/vmhVDhLer0UHL5wKNfmoSVfXtbbotopfAA l8A+del5LpBc5r/2F4HBhznWord3+CYeV80nZ/4kFPY0nQJwyj+d/YYMA7x7gpNkwWaF kL1JW7APM8bz4VvZYOzEmejKsqwSawit7rf95eIhOsF1LpIFuk+SCB+INn0Y+okmPUMm /4dbbWENsfUN/m6Q/1o5Wmf5DyA5e5Yrc82YQjOK8cTg4j9eoED3ZbmDX+T93VKS9j1I 8PlA== X-Gm-Message-State: AA+aEWamRB7vSGeg4JyCWWdwkj1t4XrtfKFdxOo5IS4T2KC0cm702yO1 KB0FjiA92S8rzbYIdfeRO68Vv0kMouU= X-Received: by 2002:a1c:410b:: with SMTP id o11mr488815wma.109.1543617945709; Fri, 30 Nov 2018 14:45:45 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:d895:e032:7b00:86cd]) by smtp.gmail.com with ESMTPSA id m6sm10561195wrv.24.2018.11.30.14.45.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:45:44 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 30 Nov 2018 23:45:34 +0100 Message-Id: <20181130224537.18936-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130224537.18936-1-ard.biesheuvel@linaro.org> References: <20181130224537.18936-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH v2 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: Liming Gao , Jaben Carsey , Laszlo Ersek 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 Reviewed-by: Jaben Carsey --- 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: Philippe Mathieu-Daudé Reviewed-by: Laszlo Ersek 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 Fri Nov 30 22:45:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152612 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4211977ljp; Fri, 30 Nov 2018 14:45:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/US/czX+At+HQw6Mngpo61xVVBhnMC39U0NVJJMAz1ghAmP481An2lC/kiRmWh372IqzFzH X-Received: by 2002:a17:902:4124:: with SMTP id e33mr7380464pld.236.1543617957462; Fri, 30 Nov 2018 14:45:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543617957; cv=none; d=google.com; s=arc-20160816; b=MB0Yx32Czdt3iGT317km11zarfzRq2SHa1fp0pSvyQH+QGYxnd26Rjlql5smfxDHZP z27/xNK28fBQt07T+65APm0mFfvDc/RmxNYaFvOeIVvFAMhlRZLTt+248v8wNYarlMFl TK/mqQ25Vxi6ieTF2uNysdWPjIs8sR2wS3I7fHESbwmTFUB0RlS/Lxa6jkTHyNeqAKyN KvN0H1vaOr5QzohYFoUcJDMdWXOb4XjT7o1vCq40eq/i4gDA8ACa+H1wCXAmErumMa3l H0J5i4nQMDdOQWxj/N26FxMws5POegAPPQfhEcnqrwzukbfoA4LptMFDH2oo5ZSoTPHn dwSg== 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=RbU876kS9Gxa3WFMM9Gje2OrsbECfLZmTRPxuWW3lw4=; b=U+mOwE/chHg8oFusPF7wao48JNEPPlRDgJnQ9WzqaNQlyuKaoa7/WjD/BweduXFsfs eP/Sw8S+EX3LX9SpH1LlM65dYUYUerqCFMjrGZ9o/0uzmPGPURRwSphTN1uJKdsEcdHx 2K4qmzz9hGMJadRYqBnh5GsSy+krQvWEDvA/IwZUPnTQ5wudpZfuy7Uznkce10Xx0E8+ 1x5ZDofIu5U0Q8GybmhdBrpzh3mwinLx8G4R7r/lP3XhPjKMFWjdCkhmpz5VEkxjON90 UXKxG4wKjzyufMJ8ZZcTj7LlBR052/6eNg63mtRoQAZBN7ICnIWQZVNkEeeqslfVP2Vh dMQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=b2qGzKag; 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 a64si5898021pge.124.2018.11.30.14.45.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:45:57 -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=b2qGzKag; 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 2234C21196821; Fri, 30 Nov 2018 14:45:51 -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::342; helo=mail-wm1-x342.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (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 BA82621196819 for ; Fri, 30 Nov 2018 14:45:48 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id z18so441410wmc.4 for ; Fri, 30 Nov 2018 14:45:48 -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=Jgs2V5O+dhgteZihKktsPhM4fWU24XfBsoeNTGnMH7s=; b=b2qGzKagXdKIU9PBOY8Ow+kzKOYF6YblqbW7v2os16sN2Ka4umfDcw96RWzk2T97Ll AeQT5IcSL4oFT1Zf8JDWatyeifmKCAZV66XMgkmId8W6cZHyCz2J3nDiZ/hhBgSp2xDG xZX7elUZJcdwTph4YsoiaBAfmp9vjOKoxREeA= 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=Jgs2V5O+dhgteZihKktsPhM4fWU24XfBsoeNTGnMH7s=; b=r2piVMJPujIafht97me5l8s4Z56zwr/Y6CIffCh19RJtyob94P5iRgsWjQBof7M4BQ 0hMIWaPENDm1EkW0RQHu2BHebtTkO18G5YN4W3gmKJa62hoiiDIukbO7Sz0vmTn0InHp vk7TOwS5t1nDXmkQKQbu4YfuEl+lRG+G9yu5GCMFxhWj6pmXfeO4UpwbfNMlU94i6WrY rg7z2/WxWMOLlmMyvp4qicO7ViALNM74kZ8TY3InacJknk7v3EmtqLV+hCOdYDToEDof 6JHd7uCPoF4UJSxGGb2VT3oXDgM33vrctKplmwt+Cp3g7EbFlq6j3a21v8e8wt2lrsev s03Q== X-Gm-Message-State: AA+aEWb+kSJ+eWQbwX59McZ7bjekFwO6Ztnzyp0Y2IF7OMgXgRlK89i0 7YMvmi5eKnyseDAAl6fGTGrbnXgZIQc= X-Received: by 2002:a1c:150d:: with SMTP id 13mr510948wmv.104.1543617946912; Fri, 30 Nov 2018 14:45:46 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:d895:e032:7b00:86cd]) by smtp.gmail.com with ESMTPSA id m6sm10561195wrv.24.2018.11.30.14.45.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:45:46 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 30 Nov 2018 23:45:35 +0100 Message-Id: <20181130224537.18936-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130224537.18936-1-ard.biesheuvel@linaro.org> References: <20181130224537.18936-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH v2 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: Liming Gao , Jaben Carsey , Laszlo Ersek 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 Reviewed-by: Jaben Carsey --- 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: Laszlo Ersek 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 Fri Nov 30 22:45:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152613 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4212026ljp; Fri, 30 Nov 2018 14:46:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/V/ZnufHZomT9eQPY6MQNrv9JZ6QYIDQhOgea8osQZVh907XCGinxPbyG4F0DPIFYCf7Ai/ X-Received: by 2002:a17:902:780a:: with SMTP id p10mr7597495pll.54.1543617961112; Fri, 30 Nov 2018 14:46:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543617961; cv=none; d=google.com; s=arc-20160816; b=jby/eBJupChjnhRZ5R3YpUfHzkLeDBrzjFoeD6aElLCzlvjnrI2LTuK7zk8vJInkcJ iaps9N+NhvnmYFyyhDlGmHQYuA/zCNYuwbmfAdMj3QBqoDdXDrLgjxiS+WoFcFzIusF/ pcBaePsHjyTm8GoQ3NBsVce4vTRiNO0uA10+WXR7awT4FAylJIJPOTFpu/kKkSLhW5yc uzXZw2HLQtqbTEZ41djB+fGcTjEnbELQ1M4Gu4m4oKgCCXdaloI8d9MN6jZuQ5FPDGPa Y5rJjY16UtqWdJ3kBItniqlJZfEEpu6FDKgvMmCkOyB94Pdlwp21+vPj7bNLeMS3CZOX 2xzg== 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=V3/4i2Ykut4wRMpYY9mb35eE5R8ruXF6WZqi28KVKBM=; b=jXFMmf7bCgwuzwp/jGD7KwKUSvQLSQHj5GVWNGLZ+r1Jaj2tLHJLN9Qjmch++f0LNL khIb1MvAglrbsgqB1Me7fRFE+3VlsEw/ZAO3kmJ01gGhnSriUhP2Y2WoE+oCO+Nwn7nc VWWFRwmwwQmIDrY2Jyt1iaSu++WVhbztmmYtQ2RnKbtaUHbepp648Gmw6NP0F1GYtgqu KIb0KvR8dubfHRs8aZjy11RPHVUIGOzNHbj34by+Hv3r9SbCCasqm4btuOXdTMIx3VF+ LEcP/ezFJCqSCwDo/Q7HpCX8x9WyX+ms2x1ThHhHUOfxN1V8c9W/k0G+9eVR27MXXx45 8LMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QbOXRFrV; 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 u25si6075344pgm.532.2018.11.30.14.46.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:46:01 -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=QbOXRFrV; 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 5707121196826; Fri, 30 Nov 2018 14:45:51 -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::32b; helo=mail-wm1-x32b.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (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 F1F3F211963D9 for ; Fri, 30 Nov 2018 14:45:49 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id c126so457262wmh.0 for ; Fri, 30 Nov 2018 14:45:49 -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=hu6mjLWNLWlb1ueQGWZH3nKMMHmDlor+nTG8xlhj0TU=; b=QbOXRFrV+VZMOUHu+9gFjntPEwLUqLKSNRjNO71Oxaaxg82fEckOutToR3kalgdbTk UrGPLE6EfAM4l0eu4DuhETpOkjuSLKKnHwcU9bfgh43zHptkrCH7p4vkqN9FPil0Wy9m TPS2qA4Zh49z9ueLVeekavRmIO9gR9CBKdJdk= 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=hu6mjLWNLWlb1ueQGWZH3nKMMHmDlor+nTG8xlhj0TU=; b=m7e3qt2ZuILfTcDasQkopgj19oHiuDs7ddfecS9BI/H7enxEuQZVrvKHJ+EQjAB2mO YsHLpxpljyQgkES1Zy+478vth+jbOnzVsNzBegBlWdM1nT2vDDzpAA5aMQFBjB0zUaQ8 Ppt+6ywKiQ6U//ByxG0fYQFbqoec1Zbatm6+Jb2gK54gWfHQU3NhLWxipQatzJ773g95 G3LCdTHOlpIel9VfZFj05STeudXeXtJN73LlA0VyWtnNdbfj/4DsXV1ecktiwFNY+v0y SmiPWqMXAqMQypFppS1V0dzBrNaTMoA33gNfX/eU1uCoyx1jF9KGn77TldsTpvACeBPs pTpg== X-Gm-Message-State: AA+aEWZTld1tWnftuGwdm6xKbEMfFFfJ29r9+ReZuo6uXji+BoLPYLrJ UBTOhA6aFcK7fVGmFbkmFLwHuC91U/g= X-Received: by 2002:a1c:7e43:: with SMTP id z64mr484079wmc.43.1543617948062; Fri, 30 Nov 2018 14:45:48 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:d895:e032:7b00:86cd]) by smtp.gmail.com with ESMTPSA id m6sm10561195wrv.24.2018.11.30.14.45.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:45:47 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 30 Nov 2018 23:45:36 +0100 Message-Id: <20181130224537.18936-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130224537.18936-1-ard.biesheuvel@linaro.org> References: <20181130224537.18936-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH v2 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: Liming Gao , Jaben Carsey , Laszlo Ersek 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 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laszlo Ersek 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 4a28f635f3a8..42dfa821624d 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 Fri Nov 30 22:45:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152614 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4212050ljp; Fri, 30 Nov 2018 14:46:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/WtAs5+rFehcmXi97Y0grCp2B+EEoYqhvwMGSPThdlROUmSyJaT4UBUJM2oP3O28TD9fpji X-Received: by 2002:a63:f444:: with SMTP id p4mr6247495pgk.124.1543617964437; Fri, 30 Nov 2018 14:46:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543617964; cv=none; d=google.com; s=arc-20160816; b=AhGTDuESXcvl9dBxAeyQ/o2u0H/H+UtaD+8mJpkk4LtgK+h7bx7Sicthz8Vg4JI3lj yNucevNEPmzuNbql1kGQh8oM492XEWDooT4fk9VwEb7YUGWHDCwhqllrxbFX4y1FnJCx UJ9VPJkzFZbNfO7MdHzrtO8Au+VuLoMtaEbJgI4ymMJgwyWZWGrReE0K7oYSIEUTxZaW XUyK8XLb23wV77OdolDVn6/ePJBIBYxDYNNFtphFrC16+AjxE463Nz4BBzkSVAGL+dl0 tztKs2CyZT3qxHeubkaTbztyA4JqNmx0F0js6GuCQbS5nV5rl71g0ZmIbkxc2u/vRSa1 Ua0g== 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=ExR8tt9T9nsGhb5rsWZBA2VUdDs91ljYQfrjL9C5o1k=; b=EuE7V1oPakHlj71R75E6yKdrIXfVi49v9BVkOi2PT38JAJiBMvU011r9BLlWhx4iol 5Df7/s5o3rKR/LG9R1TCC62fQwK9rfpmjNTr2gx/VjVaZc4QqDPd4ucbe+3MUsbaLXAT J8lervAIjhSkMriWF9V3qARwAaMo1F0v9y7czGBo7gwPjYA/73Rk3jl0z/2Hy8tkeE0h W0hiID4EBfYQGK+8MVcrXD4ttdMuepdjcGA4+EaLgDRrC0UgdvEEv5B1h3vC0CxLIqwQ xtjqLjQ+0zBNCeLK6Bmu+wHKNlYCeQf3RCUVd8qUE/+42m0a781Gd+wfWkrjgT39b9Ca nDAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="OPns/j6o"; 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 u7si6914787pfu.270.2018.11.30.14.46.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:46:04 -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="OPns/j6o"; 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 8B87121196819; Fri, 30 Nov 2018 14:45:53 -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 82D0A21196819 for ; Fri, 30 Nov 2018 14:45:51 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id r24so2634943wmh.0 for ; Fri, 30 Nov 2018 14:45:51 -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=ucnF6W0Y41p78RwIZ7h5fNgQbYsXHvpOMqUjE4y9c6c=; b=OPns/j6oMIrwWoxCt+hpGgSIq7wqPckqkrFKwNk0DCsZKzRQmEEE97IHd3uYenIC9Z he8BFuRd+haQPAwseZfEH0vmJzOofHr05a2Jz1a5zHfwmZ1Nk3jH6/vwi0HLQeOgfQ7t U8mcZCMPZFtFs5bzcfmNQx8P62PrKxay3UE3U= 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=ucnF6W0Y41p78RwIZ7h5fNgQbYsXHvpOMqUjE4y9c6c=; b=sS9O2R/5438vdlcBkj0B5ijVJprICZDba808C/k6M9zYrMbkM0LH2KsVOb268aCq7t 0q1rorv7uXcWJ5gi18BI3GA3d3jV/1xruZeaaHBI6+GctIzvM6hkK3WSp7Tc6ROBTvdg ha2pR+iyBq7pHbZb0jfYi5aMp4SFOId2l9KQkJvDsjH9H3Fk5N/GR9XGZAC83eR4yAxy jxit+UoFd5IEeRn9i6ApJqZIGhXVBDD1/cPRGx/pZCGKmqdfe5crqyzjDSN2owc91hGu Z48+lFD5w7G+u7HTrkzkrnVBRUrUc6DxQmctS5FBNRhIANYF5/E3+YORUsuLJyKDk5JL QhTQ== X-Gm-Message-State: AA+aEWb4PJzGupoZIRZalxZVPoEJOEsqfrBqxMqDMZ9jgMx+KWPKG2lu aDj/QpPMpJyRk3WgNOwUn/JyJUrwJJk= X-Received: by 2002:a7b:c8d7:: with SMTP id f23mr478061wml.121.1543617949641; Fri, 30 Nov 2018 14:45:49 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:d895:e032:7b00:86cd]) by smtp.gmail.com with ESMTPSA id m6sm10561195wrv.24.2018.11.30.14.45.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:45:48 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 30 Nov 2018 23:45:37 +0100 Message-Id: <20181130224537.18936-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130224537.18936-1-ard.biesheuvel@linaro.org> References: <20181130224537.18936-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH v2 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: Liming Gao , Jaben Carsey , Laszlo Ersek 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 Reviewed-by: Jaben Carsey --- 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: Philippe Mathieu-Daudé Reviewed-by: Laszlo Ersek 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)