public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Jayaprakash, N" <n.jayaprakash@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Jayaprakash, N" <n.jayaprakash@intel.com>
Cc: Rebecca Cran <rebecca@bsdio.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>,
	"Kloper, Dimitry" <dimitry.kloper@intel.com>
Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fix console jump to 0, 0 issue in lseek()
Date: Fri, 25 Aug 2023 10:15:02 +0000	[thread overview]
Message-ID: <PH7PR11MB5943E09B6D40BEB93501A201EEE3A@PH7PR11MB5943.namprd11.prod.outlook.com> (raw)
In-Reply-To: <177E5EE7D234A063.10408@groups.io>

Reviewed the changes and it looks good.
Also verified that the fix solves the problem.

Reviewed-by : Jayaprakash N <n.jayaprakash@intel.com>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Jayaprakash, N
Sent: Thursday, August 24, 2023 10:04 PM
To: devel@edk2.groups.io
Cc: Jayaprakash, N <n.jayaprakash@intel.com>; Rebecca Cran <rebecca@bsdio.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Kloper, Dimitry <dimitry.kloper@intel.com>
Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fix console jump to 0, 0 issue in lseek()

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4531

Python code opens console file descriptor and uses lseek() with position == 0 and SEEK_CUR as 'do nothing, check console is alive' operation.

Current implementation of daConsole ignores whence argument, this is wrong in case lseek(0, SEEK_CUR) will send cursor to (0,0).
This fix is not generic, but solves the particular situation.

Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jayaprakash N <n.jayaprakash@intel.com>
Signed-off-by: Kloper Dimitry <dimitry.kloper@intel.com>
---
 StdLib/LibC/Uefi/Devices/Console/daConsole.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/StdLib/LibC/Uefi/Devices/Console/daConsole.c b/StdLib/LibC/Uefi/Devices/Console/daConsole.c
index 56571af..ba031d6 100644
--- a/StdLib/LibC/Uefi/Devices/Console/daConsole.c
+++ b/StdLib/LibC/Uefi/Devices/Console/daConsole.c
@@ -141,8 +141,16 @@ da_ConSeek(
     EFIerrno = RETURN_UNSUPPORTED;
     return -1;
   }
-  // Everything is OK to do the final verification and "seek".
+
   Proto = (EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)Stream->Dev;
+
+  if(Position == 0 && whence == SEEK_CUR) {
+    CursorPos.XYpos.Column  = (UINT32)Proto->Mode->CursorColumn;
+    CursorPos.XYpos.Row     = (UINT32)Proto->Mode->CursorRow;
+    return CursorPos.Offset;
+  }
+
+  // Everything is OK to do the final verification and "seek".
   CursorPos.Offset = Position;
 
   EFIerrno = Proto->SetCursorPosition(Proto,
--
2.40.0.windows.1








-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108035): https://edk2.groups.io/g/devel/message/108035
Mute This Topic: https://groups.io/mt/100952873/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



      parent reply	other threads:[~2023-08-25 10:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24 16:34 [edk2-devel] [edk2-libc Patch 0/1] Fix issue with lseek function Jayaprakash, N
2023-08-24 16:34 ` [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fix console jump to 0, 0 issue in lseek() Jayaprakash, N
2023-08-24 23:39   ` Pedro Falcato
     [not found] ` <177E5EE7D234A063.10408@groups.io>
2023-08-25 10:15   ` Jayaprakash, N [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PH7PR11MB5943E09B6D40BEB93501A201EEE3A@PH7PR11MB5943.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox