From nobody Mon May 6 00:27:44 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1490597262702831.6369206533845; Sun, 26 Mar 2017 23:47:42 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8CB5D203BEBEF; Sun, 26 Mar 2017 23:47:40 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8E4F7208F79D8 for ; Sun, 26 Mar 2017 23:47:39 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Mar 2017 23:47:39 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.197.54]) by fmsmga004.fm.intel.com with ESMTP; 26 Mar 2017 23:47:37 -0700 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490597259; x=1522133259; h=from:to:cc:subject:date:message-id; bh=WIzB06vK1MN+WrS1kD6KtrcnbBPjiRcdPYKWW8eCVfU=; b=TTANOhvCwF7XSwTiifAWy5rT2chchkejCj1pHu66UIHZ2bmQaUiuF/0N L00BjMoxkrs3j3rdjXMIHiJLLa+7Xw==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,229,1486454400"; d="scan'208";a="240618993" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Mon, 27 Mar 2017 14:47:36 +0800 Message-Id: <1490597256-16356-1-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [edk2] [Patch] MdeModulePkg/DxeHttpLib: Fix the incorrect return status if URI port is invalid X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Zhang Lubo , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Zhang Lubo Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin Reviewed-by: Zhang Lubo --- MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 15 +++++++++++++++ MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c b/MdeModulePkg/Li= brary/DxeHttpLib/DxeHttpLib.c index 2ff04ff..8e29213 100644 --- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c +++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c @@ -690,18 +690,22 @@ HttpUrlGetPort ( OUT UINT16 *Port ) { CHAR8 *PortString; EFI_STATUS Status; + UINTN Index; UINTN Data; UINT32 ResultLength; HTTP_URL_PARSER *Parser; =20 if (Url =3D=3D NULL || UrlParser =3D=3D NULL || Port =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 + *Port =3D 0; + Index =3D 0; + Parser =3D (HTTP_URL_PARSER*) UrlParser; =20 if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_PORT)) =3D=3D 0) { return EFI_INVALID_PARAMETER; } @@ -721,12 +725,23 @@ HttpUrlGetPort ( return Status; } =20 PortString[ResultLength] =3D '\0'; =20 + while (Index < ResultLength) { + if (!NET_IS_DIGIT (PortString[Index])) { + return EFI_INVALID_PARAMETER; + } + Index ++; + } + Status =3D AsciiStrDecimalToUintnS (Url + Parser->FieldData[HTTP_URI_FI= ELD_PORT].Offset, (CHAR8 **) NULL, &Data); =20 + if (Data > HTTP_URI_PORT_MAX_NUM || Data < HTTP_URI_PORT_MIN_NUM) { + return EFI_INVALID_PARAMETER; + } + *Port =3D (UINT16) Data; return Status; } =20 /** diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h b/MdeModulePkg/Li= brary/DxeHttpLib/DxeHttpLib.h index 0d0ad3d..5ee0fdc 100644 --- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h +++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h @@ -1,9 +1,9 @@ /** @file Header file for HttpLib. =20 - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -48,10 +48,13 @@ Header file for HttpLib. #define HTTP_URI_FIELD_USERINFO 5 #define HTTP_URI_FIELD_HOST 6 #define HTTP_URI_FIELD_PORT 7 #define HTTP_URI_FIELD_MAX 8 =20 +#define HTTP_URI_PORT_MIN_NUM 0 +#define HTTP_URI_PORT_MAX_NUM 65535 + // // Structure to store the parse result of a HTTP URL. // typedef struct { UINT32 Offset; --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel