Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 9cd16c1

Browse files
committed
RandyX v0.1.1:
- fixed bufferoverflow issue
1 parent 463047f commit 9cd16c1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

os/kernel/core/vga_output.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
pub fn vga_output_message(message: &[u8]) {
1+
pub fn vga_output_message(_message: &[u8]) {
2+
const MAX_LEN: usize = 32;
3+
let mut message = _message;
4+
5+
if message.len() > MAX_LEN {
6+
message = b"Too many bytes to output";
7+
}
8+
29
let vga_buffer = 0xb8000 as *mut u8;
310

411
for(i, &byte) in message.iter().enumerate(){

os/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ fn panic(_info: &PanicInfo) -> ! {
2828
loop{}
2929
}
3030

31-
static HELLO: &[u8] = b"RandyX is running...";
31+
static RUNNING_MSG: &[u8] = b"RandyX is running...";
3232
#[no_mangle]
3333
pub extern "C" fn _start() -> ! {
34-
vga_output_message(HELLO);
34+
vga_output_message(RUNNING_MSG);
3535

3636
loop{}
3737
}

0 commit comments

Comments
 (0)