Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
2c095620
Commit
2c095620
authored
17 years ago
by
Yang Tse
Browse files
Options
Downloads
Patches
Plain Diff
Fix buffer size specification.
Improve handling of boundary conditions for huge requests.
parent
acd9d724
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/server/sws.c
+14
-6
14 additions, 6 deletions
tests/server/sws.c
with
14 additions
and
6 deletions
tests/server/sws.c
+
14
−
6
View file @
2c095620
...
...
@@ -132,6 +132,7 @@ const char *serverlogfile = DEFAULT_LOGFILE;
#define MAXDOCNAMELEN_TXT "139999"
#define REQUEST_KEYWORD_SIZE 256
#define REQUEST_KEYWORD_SIZE_TXT "255"
#define CMD_AUTH_REQUIRED "auth_required"
...
...
@@ -210,7 +211,8 @@ int ProcessRequest(struct httprequest *req)
/* try to figure out the request characteristics as soon as possible, but
only once! */
if
((
req
->
testno
==
DOCNUMBER_NOTHING
)
&&
sscanf
(
line
,
"%"
REQBUFSIZ_TXT
"s %"
MAXDOCNAMELEN_TXT
"s HTTP/%d.%d"
,
sscanf
(
line
,
"%"
REQUEST_KEYWORD_SIZE_TXT
"s %"
MAXDOCNAMELEN_TXT
"s HTTP/%d.%d"
,
request
,
doc
,
&
prot_major
,
...
...
@@ -528,6 +530,7 @@ static int get_request(curl_socket_t sock, struct httprequest *req)
{
int
fail
=
0
;
char
*
reqbuf
=
req
->
reqbuf
;
ssize_t
got
=
0
;
char
*
pipereq
;
int
pipereq_length
=
0
;
...
...
@@ -556,15 +559,14 @@ static int get_request(curl_socket_t sock, struct httprequest *req)
/*** end of httprequest init ***/
while
(
req
->
offset
<
REQBUFSIZ
)
{
ssize_t
got
;
while
(
req
->
offset
<
REQBUFSIZ
-
1
)
{
if
(
pipereq_length
)
{
memmove
(
reqbuf
,
pipereq
,
pipereq_length
);
got
=
pipereq_length
;
pipereq_length
=
0
;
}
else
got
=
sread
(
sock
,
reqbuf
+
req
->
offset
,
REQBUFSIZ
-
req
->
offset
);
got
=
sread
(
sock
,
reqbuf
+
req
->
offset
,
REQBUFSIZ
-
1
-
req
->
offset
);
if
(
got
<=
0
)
{
if
(
got
<
0
)
{
logmsg
(
"recv() returned error: %d"
,
SOCKERRNO
);
...
...
@@ -592,11 +594,17 @@ static int get_request(curl_socket_t sock, struct httprequest *req)
}
}
if
(
req
->
offset
>=
REQBUFSIZ
)
{
if
((
req
->
offset
==
REQBUFSIZ
-
1
)
&&
(
got
>
0
))
{
logmsg
(
"Request would overflow buffer, closing connection"
);
/* dump request received so far to external file anyway */
reqbuf
[
REQBUFSIZ
-
1
]
=
'\0'
;
fail
=
1
;
}
else
if
(
req
->
offset
>
REQBUFSIZ
-
1
)
{
logmsg
(
"Request buffer overflow, closing connection"
);
/* dump request received so far to external file anyway */
reqbuf
[
REQBUFSIZ
-
1
]
=
'\0'
;
fail
=
1
;
/* dump the request to an external file anyway */
}
else
reqbuf
[
req
->
offset
]
=
'\0'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment