Commit fb5a1f0 1 parent 0424295 commit fb5a1f0 Copy full SHA for fb5a1f0
File tree 1 file changed +16
-6
lines changed
1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -135,17 +135,27 @@ namespace ix
135
135
int contentLength = 0 ;
136
136
{
137
137
const char * p = headers[" Content-Length" ].c_str ();
138
- char * p_end{};
138
+ char * p_end {};
139
139
errno = 0 ;
140
140
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
+ {
145
145
return std::make_tuple (
146
146
false , " Error parsing HTTP Header 'Content-Length'" , httpRequest);
147
147
}
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);
149
159
}
150
160
if (contentLength < 0 )
151
161
{
You can’t perform that action at this time.
0 commit comments