From: "gechao" <gechao@greatwall.com.cn>
To: zhichao.gao@intel.com
Cc: devel@edk2.groups.io, ray.ni@intel.com, gechao <gechao@greatwall.com.cn>
Subject: [PATCH] MdeModulePkg/TerminalDxe [BUG]: Terminal fifo buffer overflow.
Date: Thu, 14 Jan 2021 11:22:59 +0800 [thread overview]
Message-ID: <ea9e75d8a4380ca28319179c99168e5de2fd0329.1610594403.git.gechao@greatwall.com.cn> (raw)
From: gechao <gechao@greatwall.com.cn>
Fix the bug of terminal fifo buffer overflow with UINT8 type.
typedef struct {
UINT8 Head;
UINT8 Tail;
UINT8 Data[RAW_FIFO_MAX_NUMBER + 1];
} RAW_DATA_FIFO;
RAW_FIFO_MAX_NUMBER is 256.
the data buffer size is 257 (Index from 0 to 256), but the max value of
the index, Head or Tail (UINT8), is 255. That means the last data of the
data buffer would be always empty if we use Head/Tail to output/input the
data correctly. And because of the incorrect buffer size the FIFO full
check "((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1)) == Head" would never meet.
Signed-off-by: gechao <gechao@greatwall.com.cn>
---
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
index 378ace13ce..360e58e847 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -37,7 +37,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/BaseLib.h>
-#define RAW_FIFO_MAX_NUMBER 256
+#define RAW_FIFO_MAX_NUMBER 255
#define FIFO_MAX_NUMBER 128
typedef struct {
--
2.25.1
next reply other threads:[~2021-01-14 3:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-14 3:22 gechao [this message]
2021-01-14 6:34 ` [PATCH] MdeModulePkg/TerminalDxe [BUG]: Terminal fifo buffer overflow Gao, Zhichao
[not found] ` <165A05B49BF7F07B.12403@groups.io>
2021-01-15 8:49 ` [edk2-devel] " Gao, Zhichao
2021-01-15 8:53 ` Wu, Hao A
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=ea9e75d8a4380ca28319179c99168e5de2fd0329.1610594403.git.gechao@greatwall.com.cn \
--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