Commit e19c37d 1 parent 0ad688a commit e19c37d Copy full SHA for e19c37d
File tree 2 files changed +6
-0
lines changed
2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ pub enum Error {
6
6
#[ error( transparent) ]
7
7
Io ( #[ from] std:: io:: Error ) ,
8
8
9
+ #[ error( "Packet length greater than maximum {0}: {1}" ) ]
10
+ InvalidPacketLen ( usize , usize ) ,
11
+
9
12
#[ error( "Invalid timecode config: {0}" ) ]
10
13
TimecodeConfig ( String ) ,
11
14
Original file line number Diff line number Diff line change @@ -159,6 +159,9 @@ impl Packet {
159
159
let ph = PrimaryHeader :: decode ( & buf[ ..PrimaryHeader :: LEN ] ) ?;
160
160
let data_len = ph. len_minus1 as usize + 1 ;
161
161
let total_len = PrimaryHeader :: LEN + data_len;
162
+ if total_len > buf. len ( ) {
163
+ return Err ( Error :: InvalidPacketLen ( Packet :: MAX_LEN , total_len) ) ;
164
+ }
162
165
file. read_exact ( & mut buf[ PrimaryHeader :: LEN ..total_len] ) ?;
163
166
164
167
Ok ( Packet {
You can’t perform that action at this time.
0 commit comments