summaryrefslogtreecommitdiff
path: root/src/libstrongswan/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/utils')
-rw-r--r--src/libstrongswan/utils/leak_detective.c24
-rw-r--r--src/libstrongswan/utils/utils.h6
-rw-r--r--src/libstrongswan/utils/utils/byteorder.h42
3 files changed, 69 insertions, 3 deletions
diff --git a/src/libstrongswan/utils/leak_detective.c b/src/libstrongswan/utils/leak_detective.c
index d0f646c31..ad67c0380 100644
--- a/src/libstrongswan/utils/leak_detective.c
+++ b/src/libstrongswan/utils/leak_detective.c
@@ -494,7 +494,7 @@ static bool register_hooks()
* List of functions using static allocation buffers or should be suppressed
* otherwise on leak report.
*/
-char *whitelist[] = {
+static char *whitelist[] = {
/* backtraces, including own */
"backtrace_create",
"strerror_safe",
@@ -551,6 +551,15 @@ char *whitelist[] = {
"xmlInitParserCtxt",
/* libcurl */
"Curl_client_write",
+ /* libsoup */
+ "soup_message_headers_append",
+ "soup_message_headers_clear",
+ "soup_message_headers_get_list",
+ "soup_message_headers_get_one",
+ "soup_session_abort",
+ "soup_session_get_type",
+ /* libldap */
+ "ldap_int_initialize",
/* ClearSilver */
"nerr_init",
/* libgcrypt */
@@ -575,17 +584,28 @@ char *whitelist[] = {
/* libapr */
"apr_pool_create_ex",
/* glib */
+ "g_output_stream_write",
+ "g_resolver_lookup_by_name",
+ "g_signal_connect_data",
+ "g_socket_connection_factory_lookup_type",
"g_type_init_with_debug_flags",
"g_type_register_static",
"g_type_class_ref",
"g_type_create_instance",
"g_type_add_interface_static",
"g_type_interface_add_prerequisite",
- "g_socket_connection_factory_lookup_type",
+ "g_private_set",
+ "g_queue_pop_tail",
/* libgpg */
"gpg_err_init",
/* gnutls */
"gnutls_global_init",
+ /* Ada runtime */
+ "system__tasking__initialize",
+ "system__tasking__initialization__abort_defer",
+ "system__tasking__stages__create_task",
+ /* in case external threads call into our code */
+ "thread_current_id",
};
/**
diff --git a/src/libstrongswan/utils/utils.h b/src/libstrongswan/utils/utils.h
index 18b17b120..0aed842b1 100644
--- a/src/libstrongswan/utils/utils.h
+++ b/src/libstrongswan/utils/utils.h
@@ -22,16 +22,20 @@
#ifndef UTILS_H_
#define UTILS_H_
+#define _GNU_SOURCE
#include <sys/types.h>
#include <stdlib.h>
#include <stddef.h>
#include <sys/time.h>
#include <string.h>
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+
#ifdef WIN32
# include "compat/windows.h"
#else
-# define _GNU_SOURCE
# include <arpa/inet.h>
# include <sys/socket.h>
# include <netdb.h>
diff --git a/src/libstrongswan/utils/utils/byteorder.h b/src/libstrongswan/utils/utils/byteorder.h
index 7c7e53420..0665ef363 100644
--- a/src/libstrongswan/utils/utils/byteorder.h
+++ b/src/libstrongswan/utils/utils/byteorder.h
@@ -44,6 +44,21 @@
#define BITFIELD5(t, a, b, c, d, e,...) struct { t e; t d; t c; t b; t a; __VA_ARGS__}
#endif
+#ifndef le16toh
+# if BYTE_ORDER == BIG_ENDIAN
+# define le16toh(x) __builtin_bswap16(x)
+# else
+# define le16toh(x) (x)
+# endif
+#endif
+#ifndef htole16
+# if BYTE_ORDER == BIG_ENDIAN
+# define htole16(x) __builtin_bswap16(x)
+# else
+# define htole16(x) (x)
+# endif
+#endif
+
#ifndef le32toh
# if BYTE_ORDER == BIG_ENDIAN
# define le32toh(x) __builtin_bswap32(x)
@@ -177,6 +192,33 @@ static inline uint64_t untoh64(void *network)
}
/**
+ * Read a 16-bit value in little-endian order from unaligned address.
+ *
+ * @param p unaligned address to read little endian value from
+ * @return host order value
+ */
+static inline uint16_t uletoh16(void *p)
+{
+ uint16_t ret;
+
+ memcpy(&ret, p, sizeof(ret));
+ ret = le16toh(ret);
+ return ret;
+}
+
+/**
+ * Write a 16-bit value in little-endian to an unaligned address.
+ *
+ * @param p host order 16-bit value
+ * @param v unaligned address to write little endian value to
+ */
+static inline void htoule16(void *p, uint16_t v)
+{
+ v = htole16(v);
+ memcpy(p, &v, sizeof(v));
+}
+
+/**
* Read a 32-bit value in little-endian order from unaligned address.
*
* @param p unaligned address to read little endian value from