public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/TerminalDxe: Fix terminal fifo buffer overflow with UINT8 type
@ 2020-12-22 10:18 gechao
  2021-01-13  6:58 ` Gao, Zhichao
  0 siblings, 1 reply; 5+ messages in thread
From: gechao @ 2020-12-22 10:18 UTC (permalink / raw)
  To: devel, zhichao.gao; +Cc: ray.ni, gechao

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-14  2:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-22 10:18 [PATCH] MdeModulePkg/TerminalDxe: Fix terminal fifo buffer overflow with UINT8 type gechao
2021-01-13  6:58 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox