File tree Expand file tree Collapse file tree 2 files changed +3
-2
lines changed Expand file tree Collapse file tree 2 files changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ impl DescriptorWriter<'_> {
6060 pub fn write ( & mut self , descriptor_type : u8 , descriptor : & [ u8 ] ) -> Result < ( ) > {
6161 let length = descriptor. len ( ) ;
6262
63- if self . position + 2 + length > self . buf . len ( ) {
63+ if ( self . position + 2 + length) > self . buf . len ( ) || ( length + 2 ) > 255 {
6464 return Err ( UsbError :: BufferOverflow ) ;
6565 }
6666
Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ pub enum UsbError {
4545 /// Parsing failed due to invalid input.
4646 ParseError ,
4747
48- /// A buffer too short for the data to read was passed.
48+ /// A buffer too short for the data to read was passed, or provided data cannot fit within
49+ /// length constraints.
4950 BufferOverflow ,
5051
5152 /// Classes attempted to allocate more endpoints than the peripheral supports.
You can’t perform that action at this time.
0 commit comments