Skip to content

Commit 1df1be6

Browse files
committed
Write null terminator as part of initial panic message format
Signed-off-by: adamperlin <adamp@nanosoft.com>
1 parent c58668d commit 1df1be6

File tree

1 file changed

+1
-11
lines changed
  • src/hyperlight_guest_bin/src

1 file changed

+1
-11
lines changed

src/hyperlight_guest_bin/src/lib.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static PANIC_BUF: Mutex<String<512>> = Mutex::new(String::new());
149149
#[inline(always)]
150150
fn _panic_handler(info: &core::panic::PanicInfo) -> ! {
151151
let mut panic_buf_guard = PANIC_BUF.lock();
152-
let write_res = write!(panic_buf_guard, "{}", info);
152+
let write_res = write!(panic_buf_guard, "{}\0", info);
153153
if write_res.is_err() {
154154
unsafe {
155155
abort_with_code_and_message(
@@ -159,16 +159,6 @@ fn _panic_handler(info: &core::panic::PanicInfo) -> ! {
159159
}
160160
}
161161

162-
let append_res = panic_buf_guard.push('\0');
163-
if append_res.is_err() {
164-
unsafe {
165-
abort_with_code_and_message(
166-
&[ErrorCode::UnknownError as u8],
167-
c"panic: message too long".as_ptr(),
168-
)
169-
}
170-
}
171-
172162
let c_str_res = CStr::from_bytes_with_nul(panic_buf_guard.as_bytes());
173163
if c_str_res.is_err() {
174164
unsafe {

0 commit comments

Comments
 (0)