Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
562cd9a4
Commit
562cd9a4
authored
Apr 16, 2013
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve security by setting size limits
parent
72c3bf16
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
HTTPServer.pm
PVE/HTTPServer.pm
+18
-7
No files found.
PVE/HTTPServer.pm
View file @
562cd9a4
...
...
@@ -27,8 +27,9 @@ use HTTP::Status qw(:constants);
use
HTTP::
Headers
;
use
HTTP::
Response
;
# fixme
# POST_MAX = 1024 * 10; # max 10K posts
my
$limit_max_headers
=
30
;
my
$limit_max_header_size
=
8
*
1024
;
my
$limit_max_post
=
16
*
1024
;
use
Data::
Dumper
;
# fixme: remove
...
...
@@ -564,11 +565,12 @@ sub file_upload_multipart {
if
(
$hdl
->
{
rbuf
}
=~
s/^(.*?)\015?\012(--\Q$boundary\E(--)? \015?\012(.*))$/$2/xs
)
{
my
(
$rest
,
$eof
)
=
(
$1
,
$3
);
my
$len
=
length
(
$rest
);
if
(
$len
<
1024
)
{
# fixme: max data size
$rstate
->
{
post_size
}
+=
$len
;
if
(
$rstate
->
{
post_size
}
<
$limit_max_post
)
{
$rstate
->
{
params
}
->
{
$rstate
->
{
fieldname
}}
=
$rest
;
$rstate
->
{
phase
}
=
$eof
?
100
:
0
;
}
else
{
syslog
('
err
',
"
for data to large - abort upload
");
syslog
('
err
',
"
for
m
data to large - abort upload
");
$rstate
->
{
phase
}
=
-
1
;
# skip
}
}
...
...
@@ -644,13 +646,16 @@ sub get_upload_filename {
sub
unshift_read_header
{
my
(
$self
,
$reqstate
,
$state
)
=
@_
;
$state
=
{}
if
!
$state
;
$state
=
{
size
=>
0
,
count
=>
0
}
if
!
$state
;
$reqstate
->
{
hdl
}
->
unshift_read
(
line
=>
sub
{
my
(
$hdl
,
$line
)
=
@_
;
eval
{
#print "$$: got header: $line\n";
# print "$$: got header: $line\n" if $self->{debug};
die
"
to many http header lines
\n
"
if
++
$state
->
{
count
}
>=
$limit_max_headers
;
die
"
http header too large
\n
"
if
(
$state
->
{
size
}
+=
length
(
$line
))
>=
$limit_max_header_size
;
my
$r
=
$reqstate
->
{
request
};
if
(
$line
eq
'')
{
...
...
@@ -761,6 +766,7 @@ sub unshift_read_header {
params
=>
decode_urlencoded
(
$r
->
url
->
query
()),
phase
=>
0
,
read
=>
0
,
post_size
=>
0
,
starttime
=>
[
gettimeofday
],
outfh
=>
$outfh
,
};
...
...
@@ -769,6 +775,11 @@ sub unshift_read_header {
return
;
}
if
(
$len
>
$limit_max_post
)
{
$self
->
error
(
$reqstate
,
501
,
"
for data too large
");
return
;
}
if
(
!
$ct
||
$ct
eq
'
application/x-www-form-urlencoded
')
{
$reqstate
->
{
hdl
}
->
unshift_read
(
chunk
=>
$len
,
sub
{
my
(
$hdl
,
$data
)
=
@_
;
...
...
@@ -804,7 +815,7 @@ sub push_request_header {
my
(
$hdl
,
$line
)
=
@_
;
eval
{
#
print "got request header: $line\n"
;
#
print "got request header: $line\n" if $self->{debug}
;
$reqstate
->
{
keep_alive
}
--
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment