NetworkPkg/IScsiDxe: Enhance the check for array boundary

Array 'TargetUrl' of size 255 may use index value(s) 255 and 256.
So enhance the boundary check to ensure the index is valid.

Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
This commit is contained in:
Shenglei Zhang 2020-04-24 17:11:07 +08:00 committed by mergify[bot]
parent c5c5c980db
commit 0f1946b662
2 changed files with 2 additions and 2 deletions

View File

@ -122,7 +122,7 @@ IScsiDhcpExtractRootPath (
//
if ((!NET_IS_DIGIT (*(Field->Str))) && (*(Field->Str) != '[')) {
ConfigNvData->DnsMode = TRUE;
if (Field->Len > sizeof (ConfigNvData->TargetUrl)) {
if ((Field->Len + 2) > sizeof (ConfigNvData->TargetUrl)) {
return EFI_INVALID_PARAMETER;
}
CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len);

View File

@ -161,7 +161,7 @@ IScsiDhcp6ExtractRootPath (
// Server name is expressed as domain name, just save it.
//
if (ConfigNvData->DnsMode) {
if (Field->Len > sizeof (ConfigNvData->TargetUrl)) {
if ((Field->Len + 2) > sizeof (ConfigNvData->TargetUrl)) {
return EFI_INVALID_PARAMETER;
}
CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len);