mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 02:46:47 +00:00
fix: 修复nttyData的buffer导致初始化时,栈溢出的问题 (#1112)
Signed-off-by: longjin <longjin@DragonOS.org>
This commit is contained in:
parent
488718dc2e
commit
13514f6695
@ -1,3 +1,4 @@
|
|||||||
|
use alloc::boxed::Box;
|
||||||
use core::intrinsics::likely;
|
use core::intrinsics::likely;
|
||||||
use core::ops::BitXor;
|
use core::ops::BitXor;
|
||||||
|
|
||||||
@ -116,8 +117,8 @@ pub struct NTtyData {
|
|||||||
echo_tail: usize,
|
echo_tail: usize,
|
||||||
|
|
||||||
/// 写者与读者共享
|
/// 写者与读者共享
|
||||||
read_buf: [u8; NTTY_BUFSIZE],
|
read_buf: Box<[u8; NTTY_BUFSIZE]>,
|
||||||
echo_buf: [u8; NTTY_BUFSIZE],
|
echo_buf: Box<[u8; NTTY_BUFSIZE]>,
|
||||||
|
|
||||||
read_flags: StaticBitmap<NTTY_BUFSIZE>,
|
read_flags: StaticBitmap<NTTY_BUFSIZE>,
|
||||||
char_map: StaticBitmap<256>,
|
char_map: StaticBitmap<256>,
|
||||||
@ -126,6 +127,7 @@ pub struct NTtyData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl NTtyData {
|
impl NTtyData {
|
||||||
|
#[inline(never)]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
read_head: 0,
|
read_head: 0,
|
||||||
@ -147,8 +149,8 @@ impl NTtyData {
|
|||||||
cursor_column: 0,
|
cursor_column: 0,
|
||||||
canon_cursor_column: 0,
|
canon_cursor_column: 0,
|
||||||
echo_tail: 0,
|
echo_tail: 0,
|
||||||
read_buf: [0; NTTY_BUFSIZE],
|
read_buf: Box::new([0; NTTY_BUFSIZE]),
|
||||||
echo_buf: [0; NTTY_BUFSIZE],
|
echo_buf: Box::new([0; NTTY_BUFSIZE]),
|
||||||
read_flags: StaticBitmap::new(),
|
read_flags: StaticBitmap::new(),
|
||||||
char_map: StaticBitmap::new(),
|
char_map: StaticBitmap::new(),
|
||||||
tty: Weak::default(),
|
tty: Weak::default(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user