summaryrefslogtreecommitdiff
path: root/src/lib/libressl/ressl_util.c
diff options
context:
space:
mode:
authorjsing <>2014-10-31 13:46:17 +0000
committerjsing <>2014-10-31 13:46:17 +0000
commitcd85e00508e178758948e7a759609d0f1e7764df (patch)
tree44ea21a19ccf529a3e38fb107d3a2d1330f58d8e /src/lib/libressl/ressl_util.c
parente83bdb8edcd9388f13b71372b277fdcce386a9b0 (diff)
downloadopenbsd-cd85e00508e178758948e7a759609d0f1e7764df.tar.gz
openbsd-cd85e00508e178758948e7a759609d0f1e7764df.tar.bz2
openbsd-cd85e00508e178758948e7a759609d0f1e7764df.zip
Rename libressl to libtls to avoid confusion and to make it easier to
distinguish between LibreSSL (the project) and libressl (the library). Discussed with many.
Diffstat (limited to 'src/lib/libressl/ressl_util.c')
-rw-r--r--src/lib/libressl/ressl_util.c81
1 files changed, 0 insertions, 81 deletions
diff --git a/src/lib/libressl/ressl_util.c b/src/lib/libressl/ressl_util.c
deleted file mode 100644
index d8b8f51738..0000000000
--- a/src/lib/libressl/ressl_util.c
+++ /dev/null
@@ -1,81 +0,0 @@
1/* $OpenBSD: ressl_util.c,v 1.2 2014/08/05 12:46:16 jsing Exp $ */
2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <stdlib.h>
19
20#include "ressl_internal.h"
21
22/*
23 * Extract the host and port from a colon separated value. For a literal IPv6
24 * address the address must be contained with square braces. If a host and
25 * port are successfully extracted, the function will return 0 and the
26 * caller is responsible for freeing the host and port. If no port is found
27 * then the function will return 1, with both host and port being NULL.
28 * On memory allocation failure -1 will be returned.
29 */
30int
31ressl_host_port(const char *hostport, char **host, char **port)
32{
33 char *h, *p, *s;
34 int rv = 1;
35
36 *host = NULL;
37 *port = NULL;
38
39 if ((s = strdup(hostport)) == NULL)
40 goto fail;
41
42 h = p = s;
43
44 /* See if this is an IPv6 literal with square braces. */
45 if (p[0] == '[') {
46 h++;
47 if ((p = strchr(s, ']')) == NULL)
48 goto done;
49 *p++ = '\0';
50 }
51
52 /* Find the port seperator. */
53 if ((p = strchr(p, ':')) == NULL)
54 goto done;
55
56 /* If there is another separator then we have issues. */
57 if (strchr(p + 1, ':') != NULL)
58 goto done;
59
60 *p++ = '\0';
61
62 if (asprintf(host, "%s", h) == -1)
63 goto fail;
64 if (asprintf(port, "%s", p) == -1)
65 goto fail;
66
67 rv = 0;
68 goto done;
69
70fail:
71 free(*host);
72 *host = NULL;
73 free(*port);
74 *port = NULL;
75 rv = -1;
76
77done:
78 free(s);
79
80 return (rv);
81}