From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: philmd@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Mon, 23 Sep 2019 03:01:05 -0700 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C2D383F4C for ; Mon, 23 Sep 2019 10:01:05 +0000 (UTC) Received: by mail-wr1-f70.google.com with SMTP id a4so4622314wrg.8 for ; Mon, 23 Sep 2019 03:01:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=q9yc/jd1uOc0SsVMfOq5J2SiCZI+QDwRBhE23zqU9Co=; b=UoVuIf3dSjsfVQlz2Dvt0EbrShv52Gfu+IMUoePuU6xApvxm+nxkhmJgbp3yzHZTnw 0MxI8U+l4Wq47qXwH/D2NJlSIcgxDTfOQPc206YPnvh7uRyQKSwJlc4l4b9+4WMvoONR 4vtJDpo4QKCPZcoB97Beu4XCd+k0O4bmJ7z9zMe3uGZrHimngCayo2SdEy+/vmZflEKZ tVXFUR+aZBCtzKOKmKwJtAUIyb8Qm/1OQE36rzQsimKKtrNzekJWJVl37XFc+SSyP7ay N9N7I8xT0OrDKxpXZTm8JUrF6rYmbPWboM9ylnP+HTBdI3R7ZHi5gJ/YYgnpW2p/p0oi NmDA== X-Gm-Message-State: APjAAAUk5CXuUPC2KQtaVeKQmxw5yAuVSWCxGuLw1Fn7Lw7hdvVNiggw 0Vqz62Y4ZEj4JDbkN4Jtp6gyvxDRVI750fCCvLjfGwHeFOFXKH4aPwmsWH0Jw0J63YmRtj0YsTv 4I1SqH80p+B8hyA== X-Received: by 2002:a1c:4886:: with SMTP id v128mr13159318wma.176.1569232863880; Mon, 23 Sep 2019 03:01:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1diXDQe67XFdt7t4gkTptfP86buwXGu4aQUUhi24sFGZaR9c9zRjDRtWWnF5XELTSyyIdkg== X-Received: by 2002:a1c:4886:: with SMTP id v128mr13159309wma.176.1569232863727; Mon, 23 Sep 2019 03:01:03 -0700 (PDT) Received: from [192.168.1.40] (240.red-88-21-68.staticip.rima-tde.net. [88.21.68.240]) by smtp.gmail.com with ESMTPSA id r6sm9588908wmh.38.2019.09.23.03.01.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Sep 2019 03:01:03 -0700 (PDT) Subject: Re: [edk2-devel] [PATCH 31/35] ShellPkg/UefiShellDebug1CommandsLib: fix ShellCloseFile() call To: devel@edk2.groups.io, lersek@redhat.com Cc: Jaben Carsey , Ray Ni , Zhichao Gao References: <20190917194935.24322-1-lersek@redhat.com> <20190917194935.24322-32-lersek@redhat.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Openpgp: id=89C1E78F601EE86C867495CBA2A3FD6EDEADC0DE; url=http://pgp.mit.edu/pks/lookup?op=get&search=0xA2A3FD6EDEADC0DE Message-ID: Date: Mon, 23 Sep 2019 12:01:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190917194935.24322-32-lersek@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 9/17/19 9:49 PM, Laszlo Ersek wrote: > In the FileBufferSave() function, we invoke ShellCloseFile() if "Directory > Can Not Be Saved". > > The ShellCloseFile() function takes a (SHELL_FILE_HANDLE*) parameter > called "FileHandle", and correctly passes the de-referenced (*FileHandle) > to EFI_SHELL_CLOSE_FILE, which takes a SHELL_FILE_HANDLE. > > However, FileBufferSave() passes SHELL_FILE_HANDLE to ShellCloseFile(), > not the expected (SHELL_FILE_HANDLE*). Correct it. > > This fixes an actual bug that has remained hidden for two reasons: > > - pointer-to-VOID converts from/to any pointer-to-object type silently, > - the bug is on an error path which has likely never fired in practice. > > Cc: Jaben Carsey > Cc: Ray Ni > Cc: Zhichao Gao > Signed-off-by: Laszlo Ersek > --- > > Notes: > tested: edit (saving a file) > > ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c > index 464f9de38e52..fd324cc4a861 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c > @@ -1462,7 +1462,7 @@ FileBufferSave ( > > if (Info != NULL && Info->Attribute & EFI_FILE_DIRECTORY) { > StatusBarSetStatusString (L"Directory Can Not Be Saved"); > - ShellCloseFile(FileHandle); > + ShellCloseFile (&FileHandle); > FreePool(Info); > return EFI_LOAD_ERROR; > } > Reviewed-by: Philippe Mathieu-Daude