From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AFSGD/U3a51bCJXWNqZJzQnfDSroorjbqZNkTLB71rTr+Mm9kA6kNlMMMWm6bEZqSuOn433yRN8upw== 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 Cc: Ard Biesheuvel , Laszlo Ersek , Yonghong Zhu , Liming Gao , Bob Feng 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: [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: , X-List-Received-Date: Thu, 29 Nov 2018 12:31:41 -0000 Content-Transfer-Encoding: 8bit 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(-) 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; -- 2.19.1