MdeModulePkg/DxeHttpLib: Fix the incorrect return status if URI port is invalid

Cc: Zhang Lubo <lubo.zhang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Zhang Lubo <lubo.zhang@intel.com>
This commit is contained in:
Jiaxin Wu
2017-03-27 14:45:50 +08:00
parent 7571a1c191
commit d3017dd96b
2 changed files with 19 additions and 1 deletions

View File

@ -692,6 +692,7 @@ HttpUrlGetPort (
{
CHAR8 *PortString;
EFI_STATUS Status;
UINTN Index;
UINTN Data;
UINT32 ResultLength;
HTTP_URL_PARSER *Parser;
@ -700,6 +701,9 @@ HttpUrlGetPort (
return EFI_INVALID_PARAMETER;
}
*Port = 0;
Index = 0;
Parser = (HTTP_URL_PARSER*) UrlParser;
if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_PORT)) == 0) {
@ -723,8 +727,19 @@ HttpUrlGetPort (
PortString[ResultLength] = '\0';
while (Index < ResultLength) {
if (!NET_IS_DIGIT (PortString[Index])) {
return EFI_INVALID_PARAMETER;
}
Index ++;
}
Status = AsciiStrDecimalToUintnS (Url + Parser->FieldData[HTTP_URI_FIELD_PORT].Offset, (CHAR8 **) NULL, &Data);
if (Data > HTTP_URI_PORT_MAX_NUM || Data < HTTP_URI_PORT_MIN_NUM) {
return EFI_INVALID_PARAMETER;
}
*Port = (UINT16) Data;
return Status;
}