Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
617726b6
Commit
617726b6
authored
Feb 25, 2007
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework a bit http socket handling to avoid uninitialized variable access.
parent
f64ef866
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
60 deletions
+60
-60
src/network/httpd.c
src/network/httpd.c
+60
-60
No files found.
src/network/httpd.c
View file @
617726b6
...
...
@@ -2035,9 +2035,9 @@ static void httpd_HostThread( httpd_host_t *host )
if
(
(
p_tls
==
NULL
)
&&
(
host
->
p_tls
!=
NULL
)
)
p_tls
=
tls_ServerSessionPrepare
(
host
->
p_tls
);
struct
pollfd
ufd
[
host
->
nfd
+
host
->
i_client
+
host
->
nfd
];
/* We have nfd listening sockets, i_client, and lay accept up to nfd new client */
struct
pollfd
ufd
[
host
->
nfd
+
host
->
i_client
];
unsigned
nfd
;
for
(
nfd
=
0
;
nfd
<
host
->
nfd
;
nfd
++
)
for
(
nfd
=
0
;
nfd
<
host
->
nfd
;
nfd
++
)
{
ufd
[
nfd
].
fd
=
host
->
fds
[
nfd
];
ufd
[
nfd
].
events
=
POLLIN
;
...
...
@@ -2414,7 +2414,7 @@ static void httpd_HostThread( httpd_host_t *host )
vlc_mutex_unlock
(
&
host
->
lock
);
/* we will wait 100ms or 20ms (not too big 'cause HTTPD_CLIENT_WAITING) */
switch
(
poll
(
ufd
,
nfd
,
b_low_delay
?
20
:
100
)
)
switch
(
poll
(
ufd
,
nfd
,
b_low_delay
?
20
:
100
)
)
{
case
-
1
:
if
(
errno
!=
EINTR
)
...
...
@@ -2427,29 +2427,73 @@ static void httpd_HostThread( httpd_host_t *host )
continue
;
}
/* Handle client sockets */
vlc_mutex_lock
(
&
host
->
lock
);
now
=
mdate
();
for
(
int
i_client
=
0
;
i_client
<
host
->
i_client
;
i_client
++
)
{
httpd_client_t
*
cl
=
host
->
client
[
i_client
];
const
struct
pollfd
*
pufd
=
&
ufd
[
host
->
nfd
+
i_client
];
assert
(
pufd
<
&
ufd
[
sizeof
(
ufd
)
/
sizeof
(
ufd
[
0
])]
);
if
(
cl
->
fd
!=
pufd
->
fd
)
continue
;
// we were not waiting for this client
if
(
pufd
->
revents
==
0
)
continue
;
// no event received
cl
->
i_activity_date
=
now
;
if
(
cl
->
i_state
==
HTTPD_CLIENT_RECEIVING
)
{
httpd_ClientRecv
(
cl
);
}
else
if
(
cl
->
i_state
==
HTTPD_CLIENT_SENDING
)
{
httpd_ClientSend
(
cl
);
}
else
if
(
cl
->
i_state
==
HTTPD_CLIENT_TLS_HS_IN
)
{
httpd_ClientTlsHsIn
(
cl
);
}
else
if
(
cl
->
i_state
==
HTTPD_CLIENT_TLS_HS_OUT
)
{
httpd_ClientTlsHsOut
(
cl
);
}
if
(
cl
->
i_mode
==
HTTPD_CLIENT_BIDIR
&&
cl
->
i_state
==
HTTPD_CLIENT_SENDING
&&
(
pufd
->
revents
&
POLLIN
)
)
{
cl
->
b_read_waiting
=
VLC_TRUE
;
}
}
vlc_mutex_unlock
(
&
host
->
lock
);
/*
accept new connections
*/
for
(
nfd
=
0
;
nfd
<
host
->
nfd
;
nfd
++
)
/*
Handle server sockets (accept new connections)
*/
for
(
nfd
=
0
;
nfd
<
host
->
nfd
;
nfd
++
)
{
httpd_client_t
*
cl
;
int
fd
;
int
i_state
=
-
1
;
assert
(
ufd
[
nfd
].
fd
==
host
->
fds
[
nfd
]);
if
(
ufd
[
nfd
].
revents
==
0
)
if
(
ufd
[
nfd
].
revents
==
0
)
continue
;
int
fd
=
net_Accept
(
host
,
host
->
fds
,
0
);
if
(
fd
==
-
1
)
/* */
fd
=
net_Accept
(
host
,
host
->
fds
,
0
);
if
(
fd
<
0
)
continue
;
int
i_state
=
0
;
if
(
p_tls
!=
NULL
)
if
(
p_tls
!=
NULL
)
{
switch
(
tls_ServerSessionHandshake
(
p_tls
,
fd
)
)
switch
(
tls_ServerSessionHandshake
(
p_tls
,
fd
)
)
{
case
-
1
:
msg_Err
(
host
,
"Rejecting TLS connection"
);
net_Close
(
fd
);
net_Close
(
fd
);
fd
=
-
1
;
p_tls
=
NULL
;
break
;
...
...
@@ -2463,11 +2507,10 @@ static void httpd_HostThread( httpd_host_t *host )
break
;
}
if
((
p_tls
==
NULL
)
!=
(
host
->
p_tls
==
NULL
)
)
if
(
(
p_tls
==
NULL
)
!=
(
host
->
p_tls
==
NULL
)
)
break
;
// wasted TLS session, cannot accept() anymore
}
httpd_client_t
*
cl
;
stats_UpdateInteger
(
host
,
host
->
p_total_counter
,
1
,
NULL
);
stats_UpdateInteger
(
host
,
host
->
p_active_counter
,
1
,
NULL
);
cl
=
httpd_ClientNew
(
fd
,
p_tls
,
now
);
...
...
@@ -2475,56 +2518,13 @@ static void httpd_HostThread( httpd_host_t *host )
vlc_mutex_lock
(
&
host
->
lock
);
TAB_APPEND
(
host
->
i_client
,
host
->
client
,
cl
);
vlc_mutex_unlock
(
&
host
->
lock
);
cl
->
i_state
=
i_state
;
// override state for TLS
if
(
i_state
!=
-
1
)
cl
->
i_state
=
i_state
;
// override state for TLS
if
(
host
->
p_tls
!=
NULL
)
break
;
// cannot accept further without new TLS session
}
/* now try all others socket */
vlc_mutex_lock
(
&
host
->
lock
);
for
(
int
i_client
=
0
;
i_client
<
host
->
i_client
;
i_client
++
)
{
httpd_client_t
*
cl
=
host
->
client
[
i_client
];
const
struct
pollfd
*
pufd
=
ufd
+
nfd
;
assert
(
pufd
<
ufd
+
(
sizeof
(
ufd
)
/
sizeof
(
ufd
[
0
])));
if
(
cl
->
fd
!=
pufd
->
fd
)
continue
;
// we were not waiting for this client
nfd
++
;
if
(
pufd
->
revents
==
0
)
continue
;
// no event received
cl
->
i_activity_date
=
now
;
if
(
cl
->
i_state
==
HTTPD_CLIENT_RECEIVING
)
{
httpd_ClientRecv
(
cl
);
}
else
if
(
cl
->
i_state
==
HTTPD_CLIENT_SENDING
)
{
httpd_ClientSend
(
cl
);
}
else
if
(
cl
->
i_state
==
HTTPD_CLIENT_TLS_HS_IN
)
{
httpd_ClientTlsHsIn
(
cl
);
}
else
if
(
cl
->
i_state
==
HTTPD_CLIENT_TLS_HS_OUT
)
{
httpd_ClientTlsHsOut
(
cl
);
}
if
(
cl
->
i_mode
==
HTTPD_CLIENT_BIDIR
&&
cl
->
i_state
==
HTTPD_CLIENT_SENDING
&&
(
pufd
->
revents
&
POLLIN
)
)
{
cl
->
b_read_waiting
=
VLC_TRUE
;
}
}
vlc_mutex_unlock
(
&
host
->
lock
);
}
if
(
p_tls
!=
NULL
)
...
...
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