Commit 754c3ef0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

tls: vlc_tls_t needs not be a VLC object

parent f48b0f3f
...@@ -38,8 +38,7 @@ typedef struct vlc_tls_creds vlc_tls_creds_t; ...@@ -38,8 +38,7 @@ typedef struct vlc_tls_creds vlc_tls_creds_t;
/** TLS session */ /** TLS session */
struct vlc_tls struct vlc_tls
{ {
VLC_COMMON_MEMBERS vlc_object_t *obj;
void *sys; void *sys;
int fd; int fd;
......
...@@ -117,13 +117,13 @@ struct vlc_h1_conn ...@@ -117,13 +117,13 @@ struct vlc_h1_conn
bool released; bool released;
}; };
#define CO(conn) ((vlc_object_t *)((conn)->tls)) #define CO(conn) ((conn)->tls->obj)
static void vlc_h1_conn_destroy(struct vlc_h1_conn *conn); static void vlc_h1_conn_destroy(struct vlc_h1_conn *conn);
static void *vlc_h1_stream_fatal(struct vlc_h1_conn *conn) static void *vlc_h1_stream_fatal(struct vlc_h1_conn *conn)
{ {
msg_Dbg(conn->tls, "connection failed"); msg_Dbg(CO(conn), "connection failed");
vlc_https_disconnect(conn->tls); vlc_https_disconnect(conn->tls);
conn->tls = NULL; conn->tls = NULL;
return NULL; return NULL;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_block.h> #include <vlc_block.h>
#include <vlc_interrupt.h> #include <vlc_interrupt.h>
#include <vlc_tls.h>
#include "h2frame.h" #include "h2frame.h"
#include "h2output.h" #include "h2output.h"
...@@ -35,7 +36,7 @@ ...@@ -35,7 +36,7 @@
#include "transport.h" #include "transport.h"
#include "message.h" #include "message.h"
#define CO(c) ((vlc_object_t *)((c)->tls)) #define CO(c) ((c)->tls->obj)
#define SO(s) CO((s)->conn) #define SO(s) CO((s)->conn)
/** HTTP/2 connection */ /** HTTP/2 connection */
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_block.h> #include <vlc_block.h>
#include <vlc_tls.h>
#include "h2frame.h" #include "h2frame.h"
#include "h2conn.h" #include "h2conn.h"
#include "message.h" #include "message.h"
...@@ -44,22 +45,24 @@ ...@@ -44,22 +45,24 @@
/* I/O callbacks */ /* I/O callbacks */
static int internal_fd = -1; static int internal_fd = -1;
static vlc_tls_t fake_tls;
ssize_t vlc_https_send(struct vlc_tls *tls, const void *buf, size_t len) ssize_t vlc_https_send(struct vlc_tls *tls, const void *buf, size_t len)
{ {
assert(tls == NULL); assert(tls == &fake_tls);
(void) buf; (void) buf;
return len; return len;
} }
ssize_t vlc_https_recv(struct vlc_tls *tls, void *buf, size_t size) ssize_t vlc_https_recv(struct vlc_tls *tls, void *buf, size_t size)
{ {
assert(tls == NULL); assert(tls == &fake_tls);
return read(internal_fd, buf, size); return read(internal_fd, buf, size);
} }
void vlc_https_disconnect(struct vlc_tls *tls) void vlc_https_disconnect(struct vlc_tls *tls)
{ {
assert(tls == NULL); assert(tls == &fake_tls);
if (close(internal_fd)) if (close(internal_fd))
assert(!"close"); assert(!"close");
} }
...@@ -87,7 +90,7 @@ static void conn_create(void) ...@@ -87,7 +90,7 @@ static void conn_create(void)
external_fd = fds[0]; external_fd = fds[0];
internal_fd = fds[1]; internal_fd = fds[1];
conn = vlc_h2_conn_create(NULL); conn = vlc_h2_conn_create(&fake_tls);
assert(conn != NULL); assert(conn != NULL);
conn_send(vlc_h2_frame_settings()); conn_send(vlc_h2_frame_settings());
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_tls.h>
#include "h2frame.h" #include "h2frame.h"
#include "h2output.h" #include "h2output.h"
#include "transport.h" #include "transport.h"
...@@ -205,7 +206,7 @@ static void *vlc_h2_output_thread(void *data) ...@@ -205,7 +206,7 @@ static void *vlc_h2_output_thread(void *data)
do do
{ {
frame = vlc_h2_output_dequeue(out); frame = vlc_h2_output_dequeue(out);
vlc_h2_frame_dump((vlc_object_t *)(out->tls), frame, "out"); vlc_h2_frame_dump(out->tls->obj, frame, "out");
} }
while (vlc_h2_frame_send(out->tls, frame) == 0); while (vlc_h2_frame_send(out->tls, frame) == 0);
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_tls.h>
#include "h2frame.h" #include "h2frame.h"
#include "h2output.h" #include "h2output.h"
#include "transport.h" #include "transport.h"
...@@ -40,12 +41,14 @@ static bool send_failure = false; ...@@ -40,12 +41,14 @@ static bool send_failure = false;
static bool expect_hello = true; static bool expect_hello = true;
static vlc_sem_t rx; static vlc_sem_t rx;
static vlc_tls_t fake_tls;
/* Callback for sent frames */ /* Callback for sent frames */
ssize_t vlc_https_send(struct vlc_tls *tls, const void *buf, size_t len) ssize_t vlc_https_send(struct vlc_tls *tls, const void *buf, size_t len)
{ {
const uint8_t *p = buf; const uint8_t *p = buf;
assert(tls == NULL); assert(tls == &fake_tls);
if (expect_hello) if (expect_hello)
{ {
...@@ -99,19 +102,19 @@ int main(void) ...@@ -99,19 +102,19 @@ int main(void)
struct vlc_h2_output *out; struct vlc_h2_output *out;
/* Dummy */ /* Dummy */
out = vlc_h2_output_create(NULL, false); out = vlc_h2_output_create(&fake_tls, false);
assert(out != NULL); assert(out != NULL);
vlc_h2_output_destroy(out); vlc_h2_output_destroy(out);
vlc_sem_init(&rx, 0); vlc_sem_init(&rx, 0);
out = vlc_h2_output_create(NULL, expect_hello = true); out = vlc_h2_output_create(&fake_tls, expect_hello = true);
assert(out != NULL); assert(out != NULL);
vlc_h2_output_destroy(out); vlc_h2_output_destroy(out);
vlc_sem_destroy(&rx); vlc_sem_destroy(&rx);
/* Success */ /* Success */
vlc_sem_init(&rx, 0); vlc_sem_init(&rx, 0);
out = vlc_h2_output_create(NULL, false); out = vlc_h2_output_create(&fake_tls, false);
assert(out != NULL); assert(out != NULL);
assert(vlc_h2_output_send_prio(out, NULL) == -1); assert(vlc_h2_output_send_prio(out, NULL) == -1);
assert(vlc_h2_output_send_prio(out, frame(0)) == 0); assert(vlc_h2_output_send_prio(out, frame(0)) == 0);
...@@ -136,7 +139,7 @@ int main(void) ...@@ -136,7 +139,7 @@ int main(void)
vlc_sem_init(&rx, 0); vlc_sem_init(&rx, 0);
counter = 10; counter = 10;
out = vlc_h2_output_create(NULL, false); out = vlc_h2_output_create(&fake_tls, false);
assert(out != NULL); assert(out != NULL);
assert(vlc_h2_output_send(out, frame(10)) == 0); assert(vlc_h2_output_send(out, frame(10)) == 0);
...@@ -150,7 +153,7 @@ int main(void) ...@@ -150,7 +153,7 @@ int main(void)
/* Failure during hello */ /* Failure during hello */
vlc_sem_init(&rx, 0); vlc_sem_init(&rx, 0);
counter = 0; counter = 0;
out = vlc_h2_output_create(NULL, expect_hello = true); out = vlc_h2_output_create(&fake_tls, expect_hello = true);
assert(out != NULL); assert(out != NULL);
vlc_sem_wait(&rx); vlc_sem_wait(&rx);
......
...@@ -98,7 +98,7 @@ static void gnutls_Deinit (void) ...@@ -98,7 +98,7 @@ static void gnutls_Deinit (void)
} }
#endif #endif
static int gnutls_Error (vlc_object_t *obj, int val) static int gnutls_Error(vlc_tls_t *tls, int val)
{ {
switch (val) switch (val)
{ {
...@@ -117,10 +117,10 @@ static int gnutls_Error (vlc_object_t *obj, int val) ...@@ -117,10 +117,10 @@ static int gnutls_Error (vlc_object_t *obj, int val)
break; break;
default: default:
msg_Err (obj, "%s", gnutls_strerror (val)); msg_Err(tls->obj, "%s", gnutls_strerror (val));
#ifndef NDEBUG #ifndef NDEBUG
if (!gnutls_error_is_fatal (val)) if (!gnutls_error_is_fatal (val))
msg_Err (obj, "Error above should be handled"); msg_Err(tls->obj, "Error above should be handled");
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
WSASetLastError (WSAECONNRESET); WSASetLastError (WSAECONNRESET);
...@@ -129,7 +129,6 @@ static int gnutls_Error (vlc_object_t *obj, int val) ...@@ -129,7 +129,6 @@ static int gnutls_Error (vlc_object_t *obj, int val)
} }
return -1; return -1;
} }
#define gnutls_Error(o, val) gnutls_Error(VLC_OBJECT(o), val)
#ifdef IOV_MAX #ifdef IOV_MAX
static ssize_t vlc_gnutls_writev (gnutls_transport_ptr_t ptr, static ssize_t vlc_gnutls_writev (gnutls_transport_ptr_t ptr,
...@@ -197,7 +196,7 @@ static void gnutls_Close (vlc_tls_t *tls) ...@@ -197,7 +196,7 @@ static void gnutls_Close (vlc_tls_t *tls)
gnutls_deinit (session); gnutls_deinit (session);
} }
static int gnutls_SessionOpen (vlc_tls_t *tls, int type, static int gnutls_SessionOpen(vlc_tls_creds_t *creds, vlc_tls_t *tls, int type,
gnutls_certificate_credentials_t x509, int fd, gnutls_certificate_credentials_t x509, int fd,
const char *const *alpn) const char *const *alpn)
{ {
...@@ -208,19 +207,19 @@ static int gnutls_SessionOpen (vlc_tls_t *tls, int type, ...@@ -208,19 +207,19 @@ static int gnutls_SessionOpen (vlc_tls_t *tls, int type,
val = gnutls_init (&session, type); val = gnutls_init (&session, type);
if (val != 0) if (val != 0)
{ {
msg_Err (tls, "cannot initialize TLS session: %s", msg_Err(creds, "cannot initialize TLS session: %s",
gnutls_strerror (val)); gnutls_strerror(val));
return VLC_EGENERIC; return VLC_EGENERIC;
} }
char *priorities = var_InheritString (tls, "gnutls-priorities"); char *priorities = var_InheritString(creds, "gnutls-priorities");
if (unlikely(priorities == NULL)) if (unlikely(priorities == NULL))
goto error; goto error;
val = gnutls_priority_set_direct (session, priorities, &errp); val = gnutls_priority_set_direct (session, priorities, &errp);
if (val < 0) if (val < 0)
msg_Err (tls, "cannot set TLS priorities \"%s\": %s", errp, msg_Err(creds, "cannot set TLS priorities \"%s\": %s", errp,
gnutls_strerror (val)); gnutls_strerror(val));
free (priorities); free (priorities);
if (val < 0) if (val < 0)
goto error; goto error;
...@@ -228,8 +227,8 @@ static int gnutls_SessionOpen (vlc_tls_t *tls, int type, ...@@ -228,8 +227,8 @@ static int gnutls_SessionOpen (vlc_tls_t *tls, int type,
val = gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509); val = gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509);
if (val < 0) if (val < 0)
{ {
msg_Err (tls, "cannot set TLS session credentials: %s", msg_Err(creds, "cannot set TLS session credentials: %s",
gnutls_strerror (val)); gnutls_strerror(val));
goto error; goto error;
} }
...@@ -280,7 +279,8 @@ error: ...@@ -280,7 +279,8 @@ error:
* 1 if more would-be blocking recv is needed, * 1 if more would-be blocking recv is needed,
* 2 if more would-be blocking send is required. * 2 if more would-be blocking send is required.
*/ */
static int gnutls_ContinueHandshake (vlc_tls_t *tls, char **restrict alp) static int gnutls_ContinueHandshake(vlc_tls_creds_t *crd, vlc_tls_t *tls,
char **restrict alp)
{ {
gnutls_session_t session = tls->sys; gnutls_session_t session = tls->sys;
int val; int val;
...@@ -291,7 +291,7 @@ static int gnutls_ContinueHandshake (vlc_tls_t *tls, char **restrict alp) ...@@ -291,7 +291,7 @@ static int gnutls_ContinueHandshake (vlc_tls_t *tls, char **restrict alp)
do do
{ {
val = gnutls_handshake (session); val = gnutls_handshake (session);
msg_Dbg (tls, "TLS handshake: %s", gnutls_strerror (val)); msg_Dbg(crd, "TLS handshake: %s", gnutls_strerror (val));
switch (val) switch (val)
{ {
...@@ -306,9 +306,9 @@ static int gnutls_ContinueHandshake (vlc_tls_t *tls, char **restrict alp) ...@@ -306,9 +306,9 @@ static int gnutls_ContinueHandshake (vlc_tls_t *tls, char **restrict alp)
while (!gnutls_error_is_fatal (val)); while (!gnutls_error_is_fatal (val));
#ifdef _WIN32 #ifdef _WIN32
msg_Dbg (tls, "Winsock error %d", WSAGetLastError ()); msg_Dbg(crd, "Winsock error %d", WSAGetLastError ());
#endif #endif
msg_Err (tls, "TLS handshake error: %s", gnutls_strerror (val)); msg_Err(crd, "TLS handshake error: %s", gnutls_strerror (val));
return -1; return -1;
done: done:
...@@ -336,7 +336,7 @@ static int gnutls_ClientSessionOpen (vlc_tls_creds_t *crd, vlc_tls_t *tls, ...@@ -336,7 +336,7 @@ static int gnutls_ClientSessionOpen (vlc_tls_creds_t *crd, vlc_tls_t *tls,
int fd, const char *hostname, int fd, const char *hostname,
const char *const *alpn) const char *const *alpn)
{ {
int val = gnutls_SessionOpen (tls, GNUTLS_CLIENT, crd->sys, fd, alpn); int val = gnutls_SessionOpen(crd, tls, GNUTLS_CLIENT, crd->sys, fd, alpn);
if (val != VLC_SUCCESS) if (val != VLC_SUCCESS)
return val; return val;
...@@ -357,7 +357,7 @@ static int gnutls_ClientHandshake(vlc_tls_creds_t *creds, vlc_tls_t *tls, ...@@ -357,7 +357,7 @@ static int gnutls_ClientHandshake(vlc_tls_creds_t *creds, vlc_tls_t *tls,
const char *host, const char *service, const char *host, const char *service,
char **restrict alp) char **restrict alp)
{ {
int val = gnutls_ContinueHandshake (tls, alp); int val = gnutls_ContinueHandshake(creds, tls, alp);
if (val) if (val)
return val; return val;
...@@ -368,8 +368,8 @@ static int gnutls_ClientHandshake(vlc_tls_creds_t *creds, vlc_tls_t *tls, ...@@ -368,8 +368,8 @@ static int gnutls_ClientHandshake(vlc_tls_creds_t *creds, vlc_tls_t *tls,
val = gnutls_certificate_verify_peers3 (session, host, &status); val = gnutls_certificate_verify_peers3 (session, host, &status);
if (val) if (val)
{ {
msg_Err (tls, "Certificate verification error: %s", msg_Err(creds, "Certificate verification error: %s",
gnutls_strerror (val)); gnutls_strerror(val));
return -1; return -1;
} }
...@@ -382,7 +382,7 @@ static int gnutls_ClientHandshake(vlc_tls_creds_t *creds, vlc_tls_t *tls, ...@@ -382,7 +382,7 @@ static int gnutls_ClientHandshake(vlc_tls_creds_t *creds, vlc_tls_t *tls,
if (gnutls_certificate_verification_status_print(status, if (gnutls_certificate_verification_status_print(status,
gnutls_certificate_type_get (session), &desc, 0) == 0) gnutls_certificate_type_get (session), &desc, 0) == 0)
{ {
msg_Err (tls, "Certificate verification failure: %s", desc.data); msg_Err(creds, "Certificate verification failure: %s", desc.data);
gnutls_free (desc.data); gnutls_free (desc.data);
} }
...@@ -400,44 +400,44 @@ static int gnutls_ClientHandshake(vlc_tls_creds_t *creds, vlc_tls_t *tls, ...@@ -400,44 +400,44 @@ static int gnutls_ClientHandshake(vlc_tls_creds_t *creds, vlc_tls_t *tls,
datum = gnutls_certificate_get_peers (session, &count); datum = gnutls_certificate_get_peers (session, &count);
if (datum == NULL || count == 0) if (datum == NULL || count == 0)
{ {
msg_Err (tls, "Peer certificate not available"); msg_Err(creds, "Peer certificate not available");
return -1; return -1;
} }
msg_Dbg (tls, "%u certificate(s) in the list", count); msg_Dbg(creds, "%u certificate(s) in the list", count);
val = gnutls_verify_stored_pubkey (NULL, NULL, host, service, val = gnutls_verify_stored_pubkey (NULL, NULL, host, service,
GNUTLS_CRT_X509, datum, 0); GNUTLS_CRT_X509, datum, 0);
const char *msg; const char *msg;
switch (val) switch (val)
{ {
case 0: case 0:
msg_Dbg (tls, "certificate key match for %s", host); msg_Dbg(creds, "certificate key match for %s", host);
return 0; return 0;
case GNUTLS_E_NO_CERTIFICATE_FOUND: case GNUTLS_E_NO_CERTIFICATE_FOUND:
msg_Dbg (tls, "no known certificates for %s", host); msg_Dbg(creds, "no known certificates for %s", host);
msg = N_("However the security certificate presented by the " msg = N_("However the security certificate presented by the "
"server is unknown and could not be authenticated by any " "server is unknown and could not be authenticated by any "
"trusted Certificate Authority."); "trusted Certificate Authority.");
break; break;
case GNUTLS_E_CERTIFICATE_KEY_MISMATCH: case GNUTLS_E_CERTIFICATE_KEY_MISMATCH:
msg_Dbg (tls, "certificate keys mismatch for %s", host); msg_Dbg(creds, "certificate keys mismatch for %s", host);
msg = N_("However the security certificate presented by the " msg = N_("However the security certificate presented by the "
"server changed since the previous visit and was not " "server changed since the previous visit and was not "
"authenticated by any trusted Certificate Authority. "); "authenticated by any trusted Certificate Authority. ");
break; break;
default: default:
msg_Err (tls, "certificate key match error for %s: %s", host, msg_Err(creds, "certificate key match error for %s: %s", host,
gnutls_strerror (val)); gnutls_strerror(val));
return -1; return -1;
} }
if (dialog_Question (tls, _("Insecure site"), if (dialog_Question(creds, _("Insecure site"),
_("You attempted to reach %s. %s\n" _("You attempted to reach %s. %s\n"
"This problem may be stem from an attempt to breach your security, " "This problem may be stem from an attempt to breach your security, "
"compromise your privacy, or a configuration error.\n\n" "compromise your privacy, or a configuration error.\n\n"
"If in doubt, abort now.\n"), "If in doubt, abort now.\n"),
_("Abort"), _("View certificate"), NULL, _("Abort"), _("View certificate"), NULL,
vlc_gettext (msg), host) != 2) vlc_gettext(msg), host) != 2)
return -1; return -1;
gnutls_x509_crt_t cert; gnutls_x509_crt_t cert;
...@@ -452,7 +452,7 @@ static int gnutls_ClientHandshake(vlc_tls_creds_t *creds, vlc_tls_t *tls, ...@@ -452,7 +452,7 @@ static int gnutls_ClientHandshake(vlc_tls_creds_t *creds, vlc_tls_t *tls,
} }
gnutls_x509_crt_deinit (cert); gnutls_x509_crt_deinit (cert);
val = dialog_Question (tls, _("Insecure site"), val = dialog_Question(creds, _("Insecure site"),
_("This is the certificate presented by %s:\n%s\n\n" _("This is the certificate presented by %s:\n%s\n\n"
"If in doubt, abort now.\n"), "If in doubt, abort now.\n"),
_("Abort"), _("Accept 24 hours"), _("Abort"), _("Accept 24 hours"),
...@@ -469,7 +469,7 @@ static int gnutls_ClientHandshake(vlc_tls_creds_t *creds, vlc_tls_t *tls, ...@@ -469,7 +469,7 @@ static int gnutls_ClientHandshake(vlc_tls_creds_t *creds, vlc_tls_t *tls,
val = gnutls_store_pubkey (NULL, NULL, host, service, val = gnutls_store_pubkey (NULL, NULL, host, service,
GNUTLS_CRT_X509, datum, expiry, 0); GNUTLS_CRT_X509, datum, expiry, 0);
if (val) if (val)
msg_Err (tls, "cannot store X.509 certificate: %s", msg_Err(creds, "cannot store X.509 certificate: %s",
gnutls_strerror (val)); gnutls_strerror (val));
return 0; return 0;
} }
...@@ -540,7 +540,8 @@ static int gnutls_ServerSessionOpen (vlc_tls_creds_t *crd, vlc_tls_t *tls, ...@@ -540,7 +540,8 @@ static int gnutls_ServerSessionOpen (vlc_tls_creds_t *crd, vlc_tls_t *tls,
vlc_tls_creds_sys_t *sys = crd->sys; vlc_tls_creds_sys_t *sys = crd->sys;
assert (hostname == NULL); assert (hostname == NULL);
return gnutls_SessionOpen (tls, GNUTLS_SERVER, sys->x509_cred, fd, alpn); return gnutls_SessionOpen(crd, tls, GNUTLS_SERVER, sys->x509_cred, fd,
alpn);
} }
static int gnutls_ServerHandshake(vlc_tls_creds_t *crd, vlc_tls_t *tls, static int gnutls_ServerHandshake(vlc_tls_creds_t *crd, vlc_tls_t *tls,
...@@ -548,7 +549,7 @@ static int gnutls_ServerHandshake(vlc_tls_creds_t *crd, vlc_tls_t *tls, ...@@ -548,7 +549,7 @@ static int gnutls_ServerHandshake(vlc_tls_creds_t *crd, vlc_tls_t *tls,
char **restrict alp) char **restrict alp)
{ {
(void) host; (void) service; (void) host; (void) service;
return gnutls_ContinueHandshake (tls, alp); return gnutls_ContinueHandshake(crd, tls, alp);
} }
/** /**
......
This diff is collapsed.
...@@ -131,22 +131,26 @@ void vlc_tls_Delete (vlc_tls_creds_t *crd) ...@@ -131,22 +131,26 @@ void vlc_tls_Delete (vlc_tls_creds_t *crd)
vlc_tls_t *vlc_tls_SessionCreate (vlc_tls_creds_t *crd, int fd, vlc_tls_t *vlc_tls_SessionCreate (vlc_tls_creds_t *crd, int fd,
const char *host, const char *const *alpn) const char *host, const char *const *alpn)
{ {
vlc_tls_t *session = vlc_custom_create (crd->p_parent, sizeof (*session), vlc_tls_t *session = malloc(sizeof (*session));
"tls session"); if (unlikely(session == NULL))
return NULL;
session->obj = crd->p_parent;
session->fd = fd;
int val = crd->open (crd, session, fd, host, alpn); int val = crd->open (crd, session, fd, host, alpn);
if (val != VLC_SUCCESS) if (val != VLC_SUCCESS)
{ {
vlc_object_release (session); free(session);
return NULL; session= NULL;
} }
session->fd = fd;
return session; return session;
} }
void vlc_tls_SessionDelete (vlc_tls_t *session) void vlc_tls_SessionDelete (vlc_tls_t *session)
{ {
session->close (session); session->close (session);
vlc_object_release (session); free(session);
} }
static void cleanup_tls(void *data) static void cleanup_tls(void *data)
...@@ -182,7 +186,7 @@ vlc_tls_t *vlc_tls_ClientSessionCreate (vlc_tls_creds_t *crd, int fd, ...@@ -182,7 +186,7 @@ vlc_tls_t *vlc_tls_ClientSessionCreate (vlc_tls_creds_t *crd, int fd,
{ {
if (val < 0) if (val < 0)
{ {
msg_Err (session, "TLS client session handshake error"); msg_Err(crd, "TLS session handshake error");
error: error:
vlc_tls_SessionDelete (session); vlc_tls_SessionDelete (session);
session = NULL; session = NULL;
...@@ -201,7 +205,7 @@ error: ...@@ -201,7 +205,7 @@ error:
canc = vlc_savecancel(); canc = vlc_savecancel();
if (val == 0) if (val == 0)
{ {
msg_Err (session, "TLS client session handshake timeout"); msg_Err(crd, "TLS session handshake timeout");
goto error; goto error;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment