From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 7A81921959CAD for ; Sat, 9 Sep 2017 17:10:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E559BC057FAD; Sun, 10 Sep 2017 00:13:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E559BC057FAD Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com Received: from lacos-laptop-7.usersys.redhat.com (ovpn-121-1.rdu2.redhat.com [10.10.121.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 600CB60BE3; Sun, 10 Sep 2017 00:13:12 +0000 (UTC) From: Laszlo Ersek To: edk2-devel-01 Cc: Ard Biesheuvel , Eric Dong , Paulo Alcantara , Ruiyu Ni , Star Zeng Date: Sun, 10 Sep 2017 02:13:00 +0200 Message-Id: <20170910001304.8628-2-lersek@redhat.com> In-Reply-To: <20170910001304.8628-1-lersek@redhat.com> References: <20170910001304.8628-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sun, 10 Sep 2017 00:13:14 +0000 (UTC) Subject: [PATCH 1/5] MdeModulePkg/UdfDxe: ASSERT() valid ReadFileInfo Flags for INLINE_DATA req 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: , X-List-Received-Date: Sun, 10 Sep 2017 00:10:20 -0000 In the ReadFile() function, if "RecordingFlags" is INLINE_DATA, then we cover the following values of "ReadFileInfo->Flags": - READ_FILE_GET_FILESIZE - READ_FILE_ALLOCATE_AND_READ - READ_FILE_SEEK_AND_READ We don't do anything (just proceed to the end of the function) if "ReadFileInfo->Flags" is anything else. In reality the above three values cover the domain of the UDF_READ_FILE_FLAGS enum type fully, and "ReadFileInfo->Flags" is only ever set internally to UdfDxe. Therefore any other flag value would be a bug in UdfDxe. ASSERT() specifically that "ReadFileInfo->Flags" has been set correctly, so that the reader is not left wondering what happens if none of the enum constants match. Cc: Ard Biesheuvel Cc: Eric Dong Cc: Paulo Alcantara Cc: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek --- MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c index 7d7f722188c5..a2ca65e5dfe8 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c @@ -953,10 +953,13 @@ ReadFile ( (VOID *)((UINT8 *)Data + ReadFileInfo->FilePosition), ReadFileInfo->FileDataSize ); ReadFileInfo->FilePosition += ReadFileInfo->FileDataSize; + } else { + ASSERT (FALSE); + return EFI_INVALID_PARAMETER; } break; case LONG_ADS_SEQUENCE: case SHORT_ADS_SEQUENCE: -- 2.14.1.3.gb7cf6e02401b