aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan')
-rw-r--r--src/libstrongswan/crypto/aead.h7
-rw-r--r--src/libstrongswan/crypto/crypters/crypter.h20
-rw-r--r--src/libstrongswan/crypto/hashers/hasher.h15
-rw-r--r--src/libstrongswan/crypto/mac.h8
-rw-r--r--src/libstrongswan/crypto/nonce_gen.h10
-rw-r--r--src/libstrongswan/crypto/prf_plus.h10
-rw-r--r--src/libstrongswan/crypto/prfs/prf.h18
-rw-r--r--src/libstrongswan/crypto/rngs/rng.h21
-rw-r--r--src/libstrongswan/crypto/signers/signer.h20
-rw-r--r--src/libstrongswan/printf_hook.h31
-rw-r--r--src/libstrongswan/threading/spinlock.c4
-rw-r--r--src/libstrongswan/utils/leak_detective.c1
12 files changed, 99 insertions, 66 deletions
diff --git a/src/libstrongswan/crypto/aead.h b/src/libstrongswan/crypto/aead.h
index 522996e80..ec526a3d9 100644
--- a/src/libstrongswan/crypto/aead.h
+++ b/src/libstrongswan/crypto/aead.h
@@ -47,9 +47,8 @@ struct aead_t {
* @param encrypted allocated encryption result
* @return TRUE if successfully encrypted
*/
- __attribute__((warn_unused_result))
bool (*encrypt)(aead_t *this, chunk_t plain, chunk_t assoc, chunk_t iv,
- chunk_t *encrypted);
+ chunk_t *encrypted) __attribute__((warn_unused_result));
/**
* Decrypt and verify data, verify associated data.
@@ -102,8 +101,8 @@ struct aead_t {
* @param key encryption and authentication key
* @return TRUE if key set successfully
*/
- __attribute__((warn_unused_result))
- bool (*set_key)(aead_t *this, chunk_t key);
+ bool (*set_key)(aead_t *this,
+ chunk_t key) __attribute__((warn_unused_result));
/**
* Destroy a aead_t.
diff --git a/src/libstrongswan/crypto/crypters/crypter.h b/src/libstrongswan/crypto/crypters/crypter.h
index 4c273059b..fe854f53d 100644
--- a/src/libstrongswan/crypto/crypters/crypter.h
+++ b/src/libstrongswan/crypto/crypters/crypter.h
@@ -92,9 +92,8 @@ struct crypter_t {
* @param encrypted chunk to allocate encrypted data, or NULL
* @return TRUE if encryption successful
*/
- __attribute__((warn_unused_result))
- bool (*encrypt) (crypter_t *this, chunk_t data, chunk_t iv,
- chunk_t *encrypted);
+ bool (*encrypt)(crypter_t *this, chunk_t data, chunk_t iv,
+ chunk_t *encrypted) __attribute__((warn_unused_result));
/**
* Decrypt a chunk of data and allocate space for the decrypted value.
@@ -108,9 +107,8 @@ struct crypter_t {
* @param encrypted chunk to allocate decrypted data, or NULL
* @return TRUE if decryption successful
*/
- __attribute__((warn_unused_result))
- bool (*decrypt) (crypter_t *this, chunk_t data, chunk_t iv,
- chunk_t *decrypted);
+ bool (*decrypt)(crypter_t *this, chunk_t data, chunk_t iv,
+ chunk_t *decrypted) __attribute__((warn_unused_result));
/**
* Get the block size of the crypto algorithm.
@@ -121,7 +119,7 @@ struct crypter_t {
*
* @return block size in bytes
*/
- size_t (*get_block_size) (crypter_t *this);
+ size_t (*get_block_size)(crypter_t *this);
/**
* Get the IV size of the crypto algorithm.
@@ -139,7 +137,7 @@ struct crypter_t {
*
* @return key size in bytes
*/
- size_t (*get_key_size) (crypter_t *this);
+ size_t (*get_key_size)(crypter_t *this);
/**
* Set the key.
@@ -149,13 +147,13 @@ struct crypter_t {
* @param key key to set
* @return TRUE if key set successfully
*/
- __attribute__((warn_unused_result))
- bool (*set_key) (crypter_t *this, chunk_t key);
+ bool (*set_key)(crypter_t *this,
+ chunk_t key) __attribute__((warn_unused_result));
/**
* Destroys a crypter_t object.
*/
- void (*destroy) (crypter_t *this);
+ void (*destroy)(crypter_t *this);
};
/**
diff --git a/src/libstrongswan/crypto/hashers/hasher.h b/src/libstrongswan/crypto/hashers/hasher.h
index fa5ff69f1..759f6a23c 100644
--- a/src/libstrongswan/crypto/hashers/hasher.h
+++ b/src/libstrongswan/crypto/hashers/hasher.h
@@ -87,8 +87,8 @@ struct hasher_t {
* @param hash pointer where the hash will be written
* @return TRUE if hash created successfully
*/
- __attribute__((warn_unused_result))
- bool (*get_hash) (hasher_t *this, chunk_t data, u_int8_t *hash);
+ bool (*get_hash)(hasher_t *this, chunk_t data,
+ u_int8_t *hash) __attribute__((warn_unused_result));
/**
* Hash data and allocate space for the hash.
@@ -101,28 +101,27 @@ struct hasher_t {
* @param hash chunk which will hold allocated hash
* @return TRUE if hash allocated successfully
*/
- __attribute__((warn_unused_result))
- bool (*allocate_hash) (hasher_t *this, chunk_t data, chunk_t *hash);
+ bool (*allocate_hash)(hasher_t *this, chunk_t data,
+ chunk_t *hash) __attribute__((warn_unused_result));
/**
* Get the size of the resulting hash.
*
* @return hash size in bytes
*/
- size_t (*get_hash_size) (hasher_t *this);
+ size_t (*get_hash_size)(hasher_t *this);
/**
* Resets the hasher's state.
*
* @return TRUE if hasher reset successfully
*/
- __attribute__((warn_unused_result))
- bool (*reset) (hasher_t *this);
+ bool (*reset)(hasher_t *this) __attribute__((warn_unused_result));
/**
* Destroys a hasher object.
*/
- void (*destroy) (hasher_t *this);
+ void (*destroy)(hasher_t *this);
};
/**
diff --git a/src/libstrongswan/crypto/mac.h b/src/libstrongswan/crypto/mac.h
index 4f952a2ad..f7b43ba39 100644
--- a/src/libstrongswan/crypto/mac.h
+++ b/src/libstrongswan/crypto/mac.h
@@ -46,8 +46,8 @@ struct mac_t {
* @param out pointer where the generated bytes will be written
* @return TRUE if mac generated successfully
*/
- __attribute__((warn_unused_result))
- bool (*get_mac)(mac_t *this, chunk_t data, u_int8_t *out);
+ bool (*get_mac)(mac_t *this, chunk_t data,
+ u_int8_t *out) __attribute__((warn_unused_result));
/**
* Get the size of the resulting MAC.
@@ -64,8 +64,8 @@ struct mac_t {
* @param key key to set
* @return TRUE if key set successfully
*/
- __attribute__((warn_unused_result))
- bool (*set_key) (mac_t *this, chunk_t key);
+ bool (*set_key)(mac_t *this,
+ chunk_t key) __attribute__((warn_unused_result));
/**
* Destroys a mac_t object.
diff --git a/src/libstrongswan/crypto/nonce_gen.h b/src/libstrongswan/crypto/nonce_gen.h
index 8461c4aa0..50f3c0090 100644
--- a/src/libstrongswan/crypto/nonce_gen.h
+++ b/src/libstrongswan/crypto/nonce_gen.h
@@ -37,8 +37,8 @@ struct nonce_gen_t {
* @param buffer pointer where the generated nonce will be written
* @return TRUE if nonce allocation was succesful, FALSE otherwise
*/
- __attribute__((warn_unused_result))
- bool (*get_nonce) (nonce_gen_t *this, size_t size, u_int8_t *buffer);
+ bool (*get_nonce)(nonce_gen_t *this, size_t size,
+ u_int8_t *buffer) __attribute__((warn_unused_result));
/**
* Generates a nonce and allocates space for it.
@@ -47,13 +47,13 @@ struct nonce_gen_t {
* @param chunk chunk which will hold the generated nonce
* @return TRUE if nonce allocation was succesful, FALSE otherwise
*/
- __attribute__((warn_unused_result))
- bool (*allocate_nonce) (nonce_gen_t *this, size_t size, chunk_t *chunk);
+ bool (*allocate_nonce)(nonce_gen_t *this, size_t size,
+ chunk_t *chunk) __attribute__((warn_unused_result));
/**
* Destroys a nonce generator object.
*/
- void (*destroy) (nonce_gen_t *this);
+ void (*destroy)(nonce_gen_t *this);
};
#endif /** NONCE_GEN_H_ @}*/
diff --git a/src/libstrongswan/crypto/prf_plus.h b/src/libstrongswan/crypto/prf_plus.h
index 92f5dd76d..f994dce16 100644
--- a/src/libstrongswan/crypto/prf_plus.h
+++ b/src/libstrongswan/crypto/prf_plus.h
@@ -38,8 +38,8 @@ struct prf_plus_t {
* @param buffer pointer where the generated bytes will be written
* @return TRUE if bytes generated successfully
*/
- __attribute__((warn_unused_result))
- bool (*get_bytes) (prf_plus_t *this, size_t length, u_int8_t *buffer);
+ bool (*get_bytes)(prf_plus_t *this, size_t length,
+ u_int8_t *buffer) __attribute__((warn_unused_result));
/**
* Allocate pseudo random bytes.
@@ -48,13 +48,13 @@ struct prf_plus_t {
* @param chunk chunk which will hold generated bytes
* @return TRUE if bytes allocated successfully
*/
- __attribute__((warn_unused_result))
- bool (*allocate_bytes) (prf_plus_t *this, size_t length, chunk_t *chunk);
+ bool (*allocate_bytes)(prf_plus_t *this, size_t length,
+ chunk_t *chunk) __attribute__((warn_unused_result));
/**
* Destroys a prf_plus_t object.
*/
- void (*destroy) (prf_plus_t *this);
+ void (*destroy)(prf_plus_t *this);
};
/**
diff --git a/src/libstrongswan/crypto/prfs/prf.h b/src/libstrongswan/crypto/prfs/prf.h
index a360a968a..46e23b244 100644
--- a/src/libstrongswan/crypto/prfs/prf.h
+++ b/src/libstrongswan/crypto/prfs/prf.h
@@ -79,8 +79,8 @@ struct prf_t {
* @param buffer pointer where the generated bytes will be written
* @return TRUE if bytes generated successfully
*/
- __attribute__((warn_unused_result))
- bool (*get_bytes) (prf_t *this, chunk_t seed, u_int8_t *buffer);
+ bool (*get_bytes)(prf_t *this, chunk_t seed,
+ u_int8_t *buffer) __attribute__((warn_unused_result));
/**
* Generates pseudo random bytes and allocate space for them.
@@ -89,15 +89,15 @@ struct prf_t {
* @param chunk chunk which will hold generated bytes
* @return TRUE if bytes allocated and generated successfully
*/
- __attribute__((warn_unused_result))
- bool (*allocate_bytes) (prf_t *this, chunk_t seed, chunk_t *chunk);
+ bool (*allocate_bytes)(prf_t *this, chunk_t seed,
+ chunk_t *chunk) __attribute__((warn_unused_result));
/**
* Get the block size of this prf_t object.
*
* @return block size in bytes
*/
- size_t (*get_block_size) (prf_t *this);
+ size_t (*get_block_size)(prf_t *this);
/**
* Get the key size of this prf_t object.
@@ -107,7 +107,7 @@ struct prf_t {
*
* @return key size in bytes
*/
- size_t (*get_key_size) (prf_t *this);
+ size_t (*get_key_size)(prf_t *this);
/**
* Set the key for this prf_t object.
@@ -115,13 +115,13 @@ struct prf_t {
* @param key key to set
* @return TRUE if key set successfully
*/
- __attribute__((warn_unused_result))
- bool (*set_key) (prf_t *this, chunk_t key);
+ bool (*set_key)(prf_t *this,
+ chunk_t key) __attribute__((warn_unused_result));
/**
* Destroys a prf object.
*/
- void (*destroy) (prf_t *this);
+ void (*destroy)(prf_t *this);
};
#endif /** PRF_H_ @}*/
diff --git a/src/libstrongswan/crypto/rngs/rng.h b/src/libstrongswan/crypto/rngs/rng.h
index c72509b54..aee829d71 100644
--- a/src/libstrongswan/crypto/rngs/rng.h
+++ b/src/libstrongswan/crypto/rngs/rng.h
@@ -56,8 +56,8 @@ struct rng_t {
* @param buffer pointer where the generated bytes will be written
* @return TRUE if bytes successfully written
*/
- __attribute__((warn_unused_result))
- bool (*get_bytes) (rng_t *this, size_t len, u_int8_t *buffer);
+ bool (*get_bytes)(rng_t *this, size_t len,
+ u_int8_t *buffer) __attribute__((warn_unused_result));
/**
* Generates random bytes and allocate space for them.
@@ -66,13 +66,13 @@ struct rng_t {
* @param chunk chunk which will hold generated bytes
* @return TRUE if allocation succeeded
*/
- __attribute__((warn_unused_result))
- bool (*allocate_bytes) (rng_t *this, size_t len, chunk_t *chunk);
+ bool (*allocate_bytes)(rng_t *this, size_t len,
+ chunk_t *chunk) __attribute__((warn_unused_result));
/**
* Destroys a rng object.
*/
- void (*destroy) (rng_t *this);
+ void (*destroy)(rng_t *this);
};
/**
@@ -82,10 +82,11 @@ struct rng_t {
* @param rng rng_t object
* @param len number of bytes to get
* @param buffer pointer where the generated bytes will be written
- * @param all TRUE if all bytes have to be non-zero
+ * @param all TRUE if all bytes have to be non-zero, FALSE for first
* @return TRUE if bytes successfully written
*/
-bool rng_get_bytes_not_zero(rng_t *rng, size_t len, u_int8_t *buffer, bool all);
+bool rng_get_bytes_not_zero(rng_t *rng, size_t len, u_int8_t *buffer,
+ bool all) __attribute__((warn_unused_result));
/**
* Wrapper around rng_t.allocate_bytes() ensuring that either all bytes or at
@@ -93,12 +94,12 @@ bool rng_get_bytes_not_zero(rng_t *rng, size_t len, u_int8_t *buffer, bool all);
*
* @param rng rng_t object
* @param len number of bytes to get
- * @param buffer pointer where the generated bytes will be written
- * @param all TRUE if all bytes have to be non-zero
+ * @param chunk chunk that stores the generated bytes (allocated)
+ * @param all TRUE if all bytes have to be non-zero, FALSE for first
* @return TRUE if bytes successfully written
*/
bool rng_allocate_bytes_not_zero(rng_t *rng, size_t len, chunk_t *chunk,
- bool all);
+ bool all) __attribute__((warn_unused_result));
diff --git a/src/libstrongswan/crypto/signers/signer.h b/src/libstrongswan/crypto/signers/signer.h
index 812a674ee..9b6bd479a 100644
--- a/src/libstrongswan/crypto/signers/signer.h
+++ b/src/libstrongswan/crypto/signers/signer.h
@@ -93,8 +93,8 @@ struct signer_t {
* @param buffer pointer where the signature will be written
* @return TRUE if signature created successfully
*/
- __attribute__((warn_unused_result))
- bool (*get_signature) (signer_t *this, chunk_t data, u_int8_t *buffer);
+ bool (*get_signature)(signer_t *this, chunk_t data,
+ u_int8_t *buffer) __attribute__((warn_unused_result));
/**
* Generate a signature and allocate space for it.
@@ -106,8 +106,8 @@ struct signer_t {
* @param chunk chunk which will hold the allocated signature
* @return TRUE if signature allocated successfully
*/
- __attribute__((warn_unused_result))
- bool (*allocate_signature) (signer_t *this, chunk_t data, chunk_t *chunk);
+ bool (*allocate_signature)(signer_t *this, chunk_t data,
+ chunk_t *chunk) __attribute__((warn_unused_result));
/**
* Verify a signature.
@@ -120,21 +120,21 @@ struct signer_t {
* @param signature a chunk containing the signature
* @return TRUE, if signature is valid, FALSE otherwise
*/
- bool (*verify_signature) (signer_t *this, chunk_t data, chunk_t signature);
+ bool (*verify_signature)(signer_t *this, chunk_t data, chunk_t signature);
/**
* Get the block size of this signature algorithm.
*
* @return block size in bytes
*/
- size_t (*get_block_size) (signer_t *this);
+ size_t (*get_block_size)(signer_t *this);
/**
* Get the key size of the signature algorithm.
*
* @return key size in bytes
*/
- size_t (*get_key_size) (signer_t *this);
+ size_t (*get_key_size)(signer_t *this);
/**
* Set the key for this object.
@@ -142,13 +142,13 @@ struct signer_t {
* @param key key to set
* @return TRUE if key set
*/
- __attribute__((warn_unused_result))
- bool (*set_key) (signer_t *this, chunk_t key);
+ bool (*set_key)(signer_t *this,
+ chunk_t key) __attribute__((warn_unused_result));
/**
* Destroys a signer_t object.
*/
- void (*destroy) (signer_t *this);
+ void (*destroy)(signer_t *this);
};
#endif /** SIGNER_H_ @}*/
diff --git a/src/libstrongswan/printf_hook.h b/src/libstrongswan/printf_hook.h
index 93026cc34..6beb4fef1 100644
--- a/src/libstrongswan/printf_hook.h
+++ b/src/libstrongswan/printf_hook.h
@@ -97,6 +97,37 @@ int vstr_wrapper_vsprintf(char *str, const char *format, va_list ap);
int vstr_wrapper_vsnprintf(char *str, size_t size, const char *format, va_list ap);
int vstr_wrapper_vasprintf(char **str, const char *format, va_list ap);
+#ifdef printf
+#undef printf
+#endif
+#ifdef fprintf
+#undef fprintf
+#endif
+#ifdef sprintf
+#undef sprintf
+#endif
+#ifdef snprintf
+#undef snprintf
+#endif
+#ifdef asprintf
+#undef asprintf
+#endif
+#ifdef vprintf
+#undef vprintf
+#endif
+#ifdef vfprintf
+#undef vfprintf
+#endif
+#ifdef vsprintf
+#undef vsprintf
+#endif
+#ifdef vsnprintf
+#undef vsnprintf
+#endif
+#ifdef vasprintf
+#undef vasprintf
+#endif
+
#define printf vstr_wrapper_printf
#define fprintf vstr_wrapper_fprintf
#define sprintf vstr_wrapper_sprintf
diff --git a/src/libstrongswan/threading/spinlock.c b/src/libstrongswan/threading/spinlock.c
index 14ac49eb4..812cf696b 100644
--- a/src/libstrongswan/threading/spinlock.c
+++ b/src/libstrongswan/threading/spinlock.c
@@ -23,6 +23,10 @@
#include "mutex.h"
#include "lock_profiler.h"
+#if defined(_POSIX_SPIN_LOCKS) && _POSIX_SPIN_LOCKS == -1
+#undef _POSIX_SPIN_LOCKS
+#endif
+
typedef struct private_spinlock_t private_spinlock_t;
/**
diff --git a/src/libstrongswan/utils/leak_detective.c b/src/libstrongswan/utils/leak_detective.c
index ed0899da2..cface0538 100644
--- a/src/libstrongswan/utils/leak_detective.c
+++ b/src/libstrongswan/utils/leak_detective.c
@@ -225,6 +225,7 @@ char *whitelist[] = {
"getpwent_r",
"setpwent",
"endpwent",
+ "getspnam_r",
/* ignore dlopen, as we do not dlclose to get proper leak reports */
"dlopen",
"dlerror",