File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -135,17 +135,27 @@ namespace ix
135135 int contentLength = 0 ;
136136 {
137137 const char * p = headers[" Content-Length" ].c_str ();
138- char * p_end{};
138+ char * p_end {};
139139 errno = 0 ;
140140 long val = std::strtol (p, &p_end, 10 );
141- if (p_end == p // invalid argument
142- || errno == ERANGE // out of range
143- || val < std::numeric_limits< int >:: min ( )
144- || val > std::numeric_limits< int >:: max ()) {
141+ if (p_end == p // invalid argument
142+ || errno == ERANGE // out of range
143+ )
144+ {
145145 return std::make_tuple (
146146 false , " Error parsing HTTP Header 'Content-Length'" , httpRequest);
147147 }
148- contentLength = val;
148+ if (val > std::numeric_limits<int >::max ())
149+ {
150+ return std::make_tuple (
151+ false , " Error: 'Content-Length' value was above max" , httpRequest);
152+ }
153+ if (val < std::numeric_limits<int >::min ())
154+ {
155+ return std::make_tuple (
156+ false , " Error: 'Content-Length' value was below min" , httpRequest);
157+ }
158+ contentLength = static_cast <int >(val);
149159 }
150160 if (contentLength < 0 )
151161 {
You can’t perform that action at this time.
0 commit comments