File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -268,12 +268,23 @@ fn outb_virtq_call(
268268
269269 let name = call. function_name . clone ( ) ;
270270 let args: Vec < ParameterValue > = call. parameters . unwrap_or ( vec ! [ ] ) ;
271- let res = host_funcs
271+
272+ let registry = host_funcs
272273 . try_lock ( )
273- . map_err ( |e| HandleOutbError :: LockFailed ( file ! ( ) , line ! ( ) , e. to_string ( ) ) ) ?
274+ . map_err ( |e| HandleOutbError :: LockFailed ( file ! ( ) , line ! ( ) , e. to_string ( ) ) ) ?;
275+
276+ let mut res = registry
274277 . call_host_function ( & name, args)
275278 . map_err ( |e| GuestError :: new ( ErrorCode :: HostFunctionError , e. to_string ( ) ) ) ;
276279
280+ // Truncate oversized error messages so the serialized response
281+ // fits in the completion buffer the guest pre-allocated.
282+ if let Err ( err) = & mut res
283+ && err. message . len ( ) > wc. capacity ( )
284+ {
285+ err. message . truncate ( wc. capacity ( ) ) ;
286+ }
287+
277288 // Serialize response: VirtqMsgHeader + FunctionCallResult
278289 let func_result = FunctionCallResult :: new ( res) ;
279290 let mut builder = flatbuffers:: FlatBufferBuilder :: new ( ) ;
Original file line number Diff line number Diff line change @@ -536,7 +536,7 @@ fn guest_malloc_abort() {
536536 } ) ;
537537
538538 // allocate a vector (on heap) that is bigger than the heap
539- let heap_size = 0x4000 ;
539+ let heap_size = 0x8000 ;
540540 let size_to_allocate = 0x10000 ;
541541 assert ! (
542542 size_to_allocate > heap_size,
@@ -585,7 +585,7 @@ fn guest_outb_with_invalid_port_poisons_sandbox() {
585585
586586#[ test]
587587fn guest_panic_no_alloc ( ) {
588- let heap_size = 0x4000 ;
588+ let heap_size = 0x8000 ;
589589
590590 let mut cfg = SandboxConfiguration :: default ( ) ;
591591 cfg. set_heap_size ( heap_size) ;
You can’t perform that action at this time.
0 commit comments