Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
949032db
Commit
949032db
authored
Nov 09, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tls: make vlc_tls_ClientSessionCreate() cancellation-safe
parent
cc80d6a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
8 deletions
+28
-8
include/vlc_tls.h
include/vlc_tls.h
+2
-1
src/network/tls.c
src/network/tls.c
+26
-7
No files found.
include/vlc_tls.h
View file @
949032db
...
...
@@ -50,7 +50,8 @@ struct vlc_tls
* Initiates a client TLS session.
*
* Performs client side of TLS handshake through a connected socket, and
* establishes a secure channel. This is a blocking network operation.
* establishes a secure channel. This is a blocking network operation and may
* be a thread cancellation point.
*
* @param fd socket through which to establish the secure channel
* @param hostname expected server name, used both as Server Name Indication
...
...
src/network/tls.c
View file @
949032db
...
...
@@ -159,13 +159,27 @@ void vlc_tls_SessionDelete (vlc_tls_t *session)
vlc_object_release
(
session
);
}
static
void
cleanup_tls
(
void
*
data
)
{
vlc_tls_t
*
session
=
data
;
vlc_tls_SessionDelete
(
session
);
}
vlc_tls_t
*
vlc_tls_ClientSessionCreate
(
vlc_tls_creds_t
*
crd
,
int
fd
,
const
char
*
host
,
const
char
*
service
,
const
char
*
const
*
alpn
,
char
**
alp
)
{
vlc_tls_t
*
session
=
vlc_tls_SessionCreate
(
crd
,
fd
,
host
,
alpn
);
vlc_tls_t
*
session
;
int
canc
,
val
;
canc
=
vlc_savecancel
();
session
=
vlc_tls_SessionCreate
(
crd
,
fd
,
host
,
alpn
);
if
(
session
==
NULL
)
{
vlc_restorecancel
(
canc
);
return
NULL
;
}
mtime_t
deadline
=
mdate
();
deadline
+=
var_InheritInteger
(
crd
,
"ipv4-timeout"
)
*
1000
;
...
...
@@ -173,13 +187,16 @@ vlc_tls_t *vlc_tls_ClientSessionCreate (vlc_tls_creds_t *crd, int fd,
struct
pollfd
ufd
[
1
];
ufd
[
0
].
fd
=
fd
;
int
val
;
vlc_cleanup_push
(
cleanup_tls
,
session
)
;
while
((
val
=
vlc_tls_SessionHandshake
(
session
,
host
,
service
,
alp
))
!=
0
)
{
if
(
val
<
0
)
{
msg_Err
(
session
,
"TLS client session handshake error"
);
goto
error
;
error:
vlc_tls_SessionDelete
(
session
);
session
=
NULL
;
break
;
}
mtime_t
now
=
mdate
();
...
...
@@ -189,16 +206,18 @@ vlc_tls_t *vlc_tls_ClientSessionCreate (vlc_tls_creds_t *crd, int fd,
assert
(
val
<=
2
);
ufd
[
0
]
.
events
=
(
val
==
1
)
?
POLLIN
:
POLLOUT
;
if
(
poll
(
ufd
,
1
,
(
deadline
-
now
)
/
1000
)
==
0
)
vlc_restorecancel
(
canc
);
val
=
poll
(
ufd
,
1
,
(
deadline
-
now
)
/
1000
);
canc
=
vlc_savecancel
();
if
(
val
==
0
)
{
msg_Err
(
session
,
"TLS client session handshake timeout"
);
goto
error
;
}
}
vlc_cleanup_pop
();
vlc_restorecancel
(
canc
);
return
session
;
error:
vlc_tls_SessionDelete
(
session
);
return
NULL
;
}
int
vlc_tls_Read
(
vlc_tls_t
*
session
,
void
*
buf
,
size_t
len
,
bool
waitall
)
...
...
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