File tree Expand file tree Collapse file tree
DnsServerCore/Dns/Security Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,14 +66,24 @@ private void Load()
6666 if ( version == 1 )
6767 {
6868 _currentSecretCreated = new DateTime ( br . ReadInt64 ( ) , DateTimeKind . Utc ) ;
69-
70- int currentLen = br . ReadInt32 ( ) ;
69+
70+ int currentLen = br . ReadInt32 ( ) ; // TODO: Validate length if between 8 and 256 bytes
71+ if ( currentLen < 8 || currentLen > 256 )
72+ throw new InvalidDataException ( "Invalid current secret length." ) ;
73+
7174 _currentSecret = br . ReadBytes ( currentLen ) ;
7275
7376 int previousLen = br . ReadInt32 ( ) ;
77+ if ( previousLen < 0 || previousLen > 256 )
78+ throw new InvalidDataException ( "Invalid previous secret length." ) ;
79+
7480 if ( previousLen > 0 )
7581 _previousSecret = br . ReadBytes ( previousLen ) ;
7682 }
83+ else
84+ {
85+ throw new InvalidDataException ( "Unsupported secret file version." ) ;
86+ }
7787 }
7888 }
7989 catch
You can’t perform that action at this time.
0 commit comments