public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: gechao@greatwall.com.cn
To: devel@edk2.groups.io, zhichao.gao@intel.com
Cc: ray.ni@intel.com, gechao <gechao@greatwall.com.cn>
Subject: [PATCH] MdeModulePkg/TerminalDxe: Fix terminal fifo buffer overflow with UINT8 type
Date: Tue, 22 Dec 2020 18:18:32 +0800	[thread overview]
Message-ID: <5d397bc53140165ed278ea5bf020b0c69acd18eb.1608632264.git.gechao@greatwall.com.cn> (raw)

From: gechao <gechao@greatwall.com.cn>

The maximum fifo buffer length is RAW_FIFO_MAX_NUMBER + 1 = 257, but the
maximum value of terminal fifo buffer index is sizeof(UINT8) - 1 = 255 with
UINT8 type, so check if fifo buffer is empty or full with below expression,
((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1)) == Head, (Tail + 1) might be
sizeof(UINT8) + 1 = 256, for UINT8 type, it does not make any sense.

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


             reply	other threads:[~2020-12-22 10:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-22 10:18 gechao [this message]
2021-01-13  6:58 ` [PATCH] MdeModulePkg/TerminalDxe: Fix terminal fifo buffer overflow with UINT8 type Gao, Zhichao
2021-01-13  9:12   ` 回复: [PATCH] MdeModulePkg/TerminalDxe: Fix terminal fifo bufferoverflow " gechao
2021-01-14  2:01     ` Gao, Zhichao
2021-01-14  2:13       ` 回复: [PATCH] MdeModulePkg/TerminalDxe: Fix terminal fifobufferoverflow " gechao

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=5d397bc53140165ed278ea5bf020b0c69acd18eb.1608632264.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