summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2569568)
raw | patch | inline | side by side (parent: 2569568)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 30 Jan 2015 10:26:49 +0000 (11:26 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 30 Jan 2015 10:26:49 +0000 (11:26 +0100) |
src/client/sock.c | patch | blob | history | |
src/include/utils/ssl.h | patch | blob | history | |
src/utils/ssl.c | patch | blob | history |
diff --git a/src/client/sock.c b/src/client/sock.c
index b67910efa4b5eb843504b825587e52a14367f465..65b6b0e3a3bc20c530b096ec72a2c61ffdf8c80d 100644 (file)
--- a/src/client/sock.c
+++ b/src/client/sock.c
return client->fd;
} /* connect_tcp */
-static void
-free_ssl_options(sdb_ssl_options_t *opts)
-{
- if (opts->ca_file)
- free(opts->ca_file);
- if (opts->key_file)
- free(opts->key_file);
- if (opts->cert_file)
- free(opts->cert_file);
- if (opts->crl_file)
- free(opts->crl_file);
- opts->ca_file = opts->key_file = opts->cert_file = opts->crl_file = NULL;
-} /* free_ssl_options */
-
/*
* public API
*/
free(client->address);
client->address = NULL;
- free_ssl_options(&client->ssl_opts);
+ sdb_ssl_free_options(&client->ssl_opts);
free(client);
} /* sdb_client_destroy */
if ((! client) || (! opts))
return -1;
- free_ssl_options(&client->ssl_opts);
+ sdb_ssl_free_options(&client->ssl_opts);
if (opts->ca_file) {
client->ssl_opts.ca_file = strdup(opts->ca_file);
}
if (ret)
- free_ssl_options(&client->ssl_opts);
+ sdb_ssl_free_options(&client->ssl_opts);
return ret;
} /* sdb_client_set_ssl_options */
index 6489f8b01f871535b9e47f24e46580f3164c7e4b..801c574ba0b7df7d663935156b25ae75dbcd0e61 100644 (file)
--- a/src/include/utils/ssl.h
+++ b/src/include/utils/ssl.h
ssize_t
sdb_ssl_session_read(sdb_ssl_session_t *session, void *buf, size_t n);
+/*
+ * sdb_ssl_free_options:
+ * Free all strings stored in the specified options. All fields will be set to
+ * NULL.
+ */
+void
+sdb_ssl_free_options(sdb_ssl_options_t *opts);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/src/utils/ssl.c b/src/utils/ssl.c
index 477d16c28ae1fe7cb2ae9cd78c270a30d2125d55..f75223c03667d18d077be5bc770b9198d254aefc 100644 (file)
--- a/src/utils/ssl.c
+++ b/src/utils/ssl.c
return 0;
} /* copy_options */
-static void
-free_options(sdb_ssl_options_t *opts)
-{
- if (opts->ca_file)
- free(opts->ca_file);
- if (opts->key_file)
- free(opts->key_file);
- if (opts->cert_file)
- free(opts->cert_file);
- if (opts->crl_file)
- free(opts->crl_file);
-} /* free_options */
-
/*
* public API
*/
if (client->ctx)
SSL_CTX_free(client->ctx);
- free_options(&client->opts);
+ sdb_ssl_free_options(&client->opts);
free(client);
} /* sdb_ssl_client_destroy */
if (server->ctx)
SSL_CTX_free(server->ctx);
- free_options(&server->opts);
+ sdb_ssl_free_options(&server->opts);
free(server);
} /* sdb_ssl_server_destroy */
return -1;
} /* sdb_ssl_session_read */
+void
+sdb_ssl_free_options(sdb_ssl_options_t *opts)
+{
+ if (! opts)
+ return;
+
+ if (opts->ca_file)
+ free(opts->ca_file);
+ if (opts->key_file)
+ free(opts->key_file);
+ if (opts->cert_file)
+ free(opts->cert_file);
+ if (opts->crl_file)
+ free(opts->crl_file);
+
+ opts->ca_file = opts->key_file = opts->cert_file = opts->crl_file = NULL;
+} /* sdb_ssl_free_options */
+
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */