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
28d09cb0
Commit
28d09cb0
authored
13 years ago
by
Yang Tse
Browse files
Options
Downloads
Patches
Plain Diff
lib582.c: fix segfault triggered when torture testing test case 582
parent
21474920
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/libtest/lib582.c
+36
-13
36 additions, 13 deletions
tests/libtest/lib582.c
with
36 additions
and
13 deletions
tests/libtest/lib582.c
+
36
−
13
View file @
28d09cb0
...
...
@@ -31,8 +31,9 @@
struct
Sockets
{
curl_socket_t
*
sockets
;
int
count
;
curl_socket_t
*
sockets
;
int
count
;
/* number of sockets actually stored in array */
int
max_count
;
/* max number of sockets that fit in allocated array */
};
struct
ReadWriteSockets
...
...
@@ -52,8 +53,9 @@ static void removeFd(struct Sockets* sockets, curl_socket_t fd, int mention)
for
(
i
=
0
;
i
<
sockets
->
count
;
++
i
)
{
if
(
sockets
->
sockets
[
i
]
==
fd
)
{
memmove
(
&
sockets
->
sockets
[
i
],
&
sockets
->
sockets
[
i
+
1
],
sizeof
(
curl_socket_t
)
*
(
sockets
->
count
-
i
-
1
));
if
(
i
<
sockets
->
count
-
1
)
memmove
(
&
sockets
->
sockets
[
i
],
&
sockets
->
sockets
[
i
+
1
],
sizeof
(
curl_socket_t
)
*
(
sockets
->
count
-
(
i
+
1
)));
--
sockets
->
count
;
}
}
...
...
@@ -70,8 +72,29 @@ static void addFd(struct Sockets* sockets, curl_socket_t fd, const char *what)
*/
fprintf
(
stderr
,
"Add socket fd %d for %s
\n
"
,
(
int
)
fd
,
what
);
removeFd
(
sockets
,
fd
,
0
);
sockets
->
sockets
=
realloc
(
sockets
->
sockets
,
sizeof
(
curl_socket_t
)
*
(
sockets
->
count
+
1
));
/*
* Allocate array storage when required.
*/
if
(
!
sockets
->
sockets
)
{
sockets
->
sockets
=
malloc
(
sizeof
(
curl_socket_t
)
*
20U
);
if
(
!
sockets
->
sockets
)
return
;
sockets
->
max_count
=
20
;
}
else
if
(
sockets
->
count
+
1
>
sockets
->
max_count
)
{
curl_socket_t
*
oldptr
=
sockets
->
sockets
;
sockets
->
sockets
=
realloc
(
oldptr
,
sizeof
(
curl_socket_t
)
*
(
sockets
->
max_count
+
20
));
if
(
!
sockets
->
sockets
)
{
/* cleanup in test_cleanup */
sockets
->
sockets
=
oldptr
;
return
;
}
sockets
->
max_count
+=
20
;
}
/*
* Add file descriptor to array.
*/
sockets
->
sockets
[
sockets
->
count
]
=
fd
;
++
sockets
->
count
;
}
...
...
@@ -175,8 +198,8 @@ static void updateFdSet(struct Sockets* sockets, fd_set* fdset,
}
}
static
void
notifyCurl
(
CURL
*
curl
,
curl_socket_t
s
,
int
evBitmask
,
const
char
*
info
)
static
void
notifyCurl
(
CURL
M
*
curl
,
curl_socket_t
s
,
int
evBitmask
,
const
char
*
info
)
{
int
numhandles
=
0
;
CURLMcode
result
=
curl_multi_socket_action
(
curl
,
s
,
evBitmask
,
&
numhandles
);
...
...
@@ -189,8 +212,8 @@ static void notifyCurl(CURL* curl, curl_socket_t s, int evBitmask,
/**
* Invoke curl when a file descriptor is set.
*/
static
void
checkFdSet
(
CURL
*
curl
,
struct
Sockets
*
sockets
,
fd_set
*
fdset
,
int
evBitmask
,
const
char
*
name
)
static
void
checkFdSet
(
CURL
M
*
curl
,
struct
Sockets
*
sockets
,
fd_set
*
fdset
,
int
evBitmask
,
const
char
*
name
)
{
int
i
;
for
(
i
=
0
;
i
<
sockets
->
count
;
++
i
)
{
...
...
@@ -211,7 +234,7 @@ int test(char *URL)
CURLM
*
m
=
NULL
;
struct
timeval
ml_start
;
char
ml_timedout
=
FALSE
;
struct
ReadWriteSockets
sockets
=
{{
0
,
0
},
{
0
,
0
}};
struct
ReadWriteSockets
sockets
=
{{
NULL
,
0
,
0
},
{
NULL
,
0
,
0
}};
struct
timeval
timeout
=
{
-
1
,
0
};
int
success
=
0
;
...
...
@@ -364,9 +387,9 @@ test_cleanup:
}
fclose
(
hd_src
);
/* close the local file */
if
(
sockets
.
read
.
sockets
!=
0
)
if
(
sockets
.
read
.
sockets
)
free
(
sockets
.
read
.
sockets
);
if
(
sockets
.
write
.
sockets
!=
0
)
if
(
sockets
.
write
.
sockets
)
free
(
sockets
.
write
.
sockets
);
curl_global_cleanup
();
...
...
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