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::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-Google-Smtp-Source: AFSGD/WzLxC8JINYdO0AOas1rdax85njxU4nJkccvRanYHBKRzp0BnA1SXrMl4pz0DwC35mI2xsrSQ== 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 Cc: Ard Biesheuvel , Laszlo Ersek , Yonghong Zhu , Liming Gao , Bob Feng , Jaben Carsey 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: [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: , X-List-Received-Date: Fri, 30 Nov 2018 22:45:49 -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 Reviewed-by: Jaben Carsey --- 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