File tree 2 files changed +7
-0
lines changed
2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -621,6 +621,8 @@ pub enum AmlError {
621
621
InvalidRegionSpace ( u8 ) ,
622
622
/// Produced when a `DefPackage` contains a different number of elements to the package's length.
623
623
InvalidPackage ,
624
+ /// Produced when a `DefBuffer` contains more bytes that its size.
625
+ MalformedBuffer ,
624
626
/// Emitted by a parser when it's clear that the stream doesn't encode the object parsed by
625
627
/// that parser (e.g. the wrong opcode starts the stream). This is handled specially by some
626
628
/// parsers such as `or` and `choice!`.
Original file line number Diff line number Diff line change @@ -102,6 +102,11 @@ where
102
102
pkg_length ( ) . then ( term_arg ( ) ) . feed ( |( pkg_length, buffer_size) | {
103
103
take_to_end_of_pkglength ( pkg_length) . map_with_context ( move |bytes, context| {
104
104
let buffer_size = try_with_context ! ( context, buffer_size. as_integer( context) ) as usize ;
105
+
106
+ if buffer_size < bytes. len ( ) {
107
+ return ( Err ( AmlError :: MalformedBuffer ) , context) ;
108
+ }
109
+
105
110
let mut buffer = vec ! [ 0 ; buffer_size] ;
106
111
buffer. copy_from_slice ( bytes) ;
107
112
( Ok ( buffer) , context)
You can’t perform that action at this time.
0 commit comments