summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2015-09-09 14:32:07 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2015-09-09 14:32:07 +0000
commit0030d75585823505504d659ad3c3b8ea693c7c39 (patch)
tree5893e4114b30400c69cf6729958e34ef4fa7f1ee
parent522f4e7aee3e588cc847d4f0914f1a9b48396894 (diff)
Only take ownership of a socket if we allocated it within libtls. If we are
passed a socket then the caller is responsible for closing it. ok bcook@
-rw-r--r--lib/libtls/tls_client.c6
-rw-r--r--lib/libtls/tls_server.c10
2 files changed, 5 insertions, 11 deletions
diff --git a/lib/libtls/tls_client.c b/lib/libtls/tls_client.c
index 55fb49ff782..81b55104311 100644
--- a/lib/libtls/tls_client.c
+++ b/lib/libtls/tls_client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tls_client.c,v 1.22 2015/09/08 15:29:34 jsing Exp $ */
+/* $OpenBSD: tls_client.c,v 1.23 2015/09/09 14:32:06 jsing Exp $ */
/*
* Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
*
@@ -145,6 +145,8 @@ tls_connect_servername(struct tls *ctx, const char *host, const char *port,
goto err;
}
+ ctx->socket = s;
+
rv = 0;
err:
@@ -157,8 +159,6 @@ err:
int
tls_connect_socket(struct tls *ctx, int s, const char *servername)
{
- ctx->socket = s;
-
return tls_connect_fds(ctx, s, s, servername);
}
diff --git a/lib/libtls/tls_server.c b/lib/libtls/tls_server.c
index bb29c7ce425..190682e630a 100644
--- a/lib/libtls/tls_server.c
+++ b/lib/libtls/tls_server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tls_server.c,v 1.10 2015/08/27 15:26:50 jsing Exp $ */
+/* $OpenBSD: tls_server.c,v 1.11 2015/09/09 14:32:06 jsing Exp $ */
/*
* Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
*
@@ -148,11 +148,5 @@ err:
int
tls_accept_socket(struct tls *ctx, struct tls **cctx, int socket)
{
- int rv;
-
- rv = tls_accept_fds(ctx, cctx, socket, socket);
- if (*cctx != NULL)
- (*cctx)->socket = socket;
-
- return (rv);
+ return (tls_accept_fds(ctx, cctx, socket, socket));
}