File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ use mucell::MuCell;
2020use uany:: { UnsafeAnyExt } ;
2121use unicase:: UniCase ;
2222
23- use { http, HttpResult } ;
23+ use { http, HttpResult , HttpError } ;
2424
2525pub use self :: shared:: { Encoding , QualityItem , qitem} ;
2626pub use self :: common:: * ;
@@ -118,6 +118,8 @@ pub struct Headers {
118118 data : HashMap < HeaderName , MuCell < Item > >
119119}
120120
121+ const MAX_HEADERS_COUNT : u8 = 100 ;
122+
121123impl Headers {
122124
123125 /// Creates a new, empty headers map.
@@ -130,6 +132,7 @@ impl Headers {
130132 #[ doc( hidden) ]
131133 pub fn from_raw < R : Reader > ( rdr : & mut R ) -> HttpResult < Headers > {
132134 let mut headers = Headers :: new ( ) ;
135+ let mut count = 0u8 ;
133136 loop {
134137 match try!( http:: read_header ( rdr) ) {
135138 Some ( ( name, value) ) => {
@@ -145,6 +148,11 @@ impl Headers {
145148 // Unreachable
146149 _ => { }
147150 } ;
151+ count += 1 ;
152+ if count > MAX_HEADERS_COUNT {
153+ debug ! ( "Too many headers, aborting" ) ;
154+ return Err ( HttpError :: HttpHeaderError )
155+ }
148156 } ,
149157 None => break ,
150158 }
You can’t perform that action at this time.
0 commit comments