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; }