summaryrefslogtreecommitdiff
path: root/src/libstrongswan
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan')
-rw-r--r--src/libstrongswan/Makefile.am10
-rw-r--r--src/libstrongswan/Makefile.in450
-rw-r--r--src/libstrongswan/asn1/asn1.c16
-rw-r--r--src/libstrongswan/asn1/asn1_parser.c70
-rw-r--r--src/libstrongswan/asn1/asn1_parser.h27
-rw-r--r--src/libstrongswan/collections/array.c9
-rw-r--r--src/libstrongswan/collections/enumerator.c368
-rw-r--r--src/libstrongswan/collections/enumerator.h70
-rw-r--r--src/libstrongswan/collections/hashtable.c10
-rw-r--r--src/libstrongswan/collections/linked_list.c70
-rw-r--r--src/libstrongswan/collections/linked_list.h56
-rw-r--r--src/libstrongswan/credentials/auth_cfg.c21
-rw-r--r--src/libstrongswan/credentials/credential_factory.c26
-rw-r--r--src/libstrongswan/credentials/credential_manager.c54
-rw-r--r--src/libstrongswan/credentials/keys/public_key.c9
-rw-r--r--src/libstrongswan/credentials/sets/auth_cfg_wrapper.c36
-rw-r--r--src/libstrongswan/credentials/sets/callback_cred.c10
-rw-r--r--src/libstrongswan/credentials/sets/cert_cache.c38
-rw-r--r--src/libstrongswan/credentials/sets/mem_cred.c230
-rw-r--r--src/libstrongswan/credentials/sets/mem_cred.h2
-rw-r--r--src/libstrongswan/credentials/sets/ocsp_response_wrapper.c35
-rw-r--r--src/libstrongswan/crypto/crypto_factory.c228
-rw-r--r--src/libstrongswan/crypto/hashers/hash_algorithm_set.c17
-rw-r--r--src/libstrongswan/library.c13
-rw-r--r--src/libstrongswan/math/libnttfft/Makefile.in2
-rw-r--r--src/libstrongswan/math/libnttfft/tests/Makefile.in2
-rw-r--r--src/libstrongswan/networking/tun_device.c32
-rw-r--r--src/libstrongswan/plugins/acert/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/aes/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/aesni/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/af_alg/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_ops.c4
-rw-r--r--src/libstrongswan/plugins/agent/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/bliss/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/bliss/tests/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/blowfish/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/ccm/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/chapoly/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/cmac/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/constraints/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/ctr/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/curl/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/curve25519/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/des/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/dnskey/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/files/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/fips_prf/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/gcm/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/gcrypt/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/gmp/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c7
-rw-r--r--src/libstrongswan/plugins/hmac/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/keychain/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/ldap/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/md4/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/md5/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/mgf1/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/mysql/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/mysql/mysql_database.c21
-rw-r--r--src/libstrongswan/plugins/newhope/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/newhope/tests/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/nonce/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/ntru/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/openssl/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_crl.c11
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_pkcs7.c18
-rw-r--r--src/libstrongswan/plugins/padlock/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/pem/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/pem/pem_builder.c6
-rw-r--r--src/libstrongswan/plugins/pgp/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/pkcs1/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/pkcs11/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/pkcs11/pkcs11_creds.c38
-rw-r--r--src/libstrongswan/plugins/pkcs11/pkcs11_library.c22
-rw-r--r--src/libstrongswan/plugins/pkcs11/pkcs11_manager.c10
-rw-r--r--src/libstrongswan/plugins/pkcs12/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/pkcs7/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/pkcs7/pkcs7_signed_data.c9
-rw-r--r--src/libstrongswan/plugins/pkcs8/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/plugin_constructors.py60
-rw-r--r--src/libstrongswan/plugins/plugin_loader.c203
-rw-r--r--src/libstrongswan/plugins/plugin_loader.h10
-rw-r--r--src/libstrongswan/plugins/pubkey/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/random/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/rc2/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/rdrand/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/revocation/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/sha1/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/sha2/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/sha3/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/soup/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/sqlite/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/sqlite/sqlite_database.c33
-rw-r--r--src/libstrongswan/plugins/sshkey/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/test_vectors/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/unbound/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/winhttp/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/x509/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/x509/x509_ac.c44
-rw-r--r--src/libstrongswan/plugins/x509/x509_cert.c309
-rw-r--r--src/libstrongswan/plugins/x509/x509_crl.c54
-rw-r--r--src/libstrongswan/plugins/x509/x509_ocsp_response.c54
-rw-r--r--src/libstrongswan/plugins/x509/x509_pkcs10.c16
-rw-r--r--src/libstrongswan/plugins/xcbc/Makefile.in2
-rw-r--r--src/libstrongswan/processing/processor.c13
-rw-r--r--src/libstrongswan/settings/settings.c67
-rw-r--r--src/libstrongswan/tests/Makefile.in2
-rw-r--r--src/libstrongswan/tests/suites/test_asn1_parser.c106
-rw-r--r--src/libstrongswan/tests/suites/test_enumerator.c50
-rw-r--r--src/libstrongswan/tests/suites/test_linked_list.c111
-rw-r--r--src/libstrongswan/tests/test_suite.h2
-rw-r--r--src/libstrongswan/utils/backtrace.c9
-rw-r--r--src/libstrongswan/utils/chunk.c2
-rw-r--r--src/libstrongswan/utils/identification.c20
-rw-r--r--src/libstrongswan/utils/leak_detective.c3
-rw-r--r--src/libstrongswan/utils/utils.h48
116 files changed, 2223 insertions, 1166 deletions
diff --git a/src/libstrongswan/Makefile.am b/src/libstrongswan/Makefile.am
index f6d6f5465..b4d8452f1 100644
--- a/src/libstrongswan/Makefile.am
+++ b/src/libstrongswan/Makefile.am
@@ -195,6 +195,7 @@ endif
EXTRA_DIST = \
asn1/oid.txt asn1/oid.pl \
crypto/proposal/proposal_keywords_static.txt \
+plugins/plugin_constructors.py \
Android.mk
BUILT_SOURCES = \
@@ -220,6 +221,15 @@ $(srcdir)/crypto/proposal/proposal_keywords_static.c: $(srcdir)/crypto/proposal/
$(GPERF) -N proposal_get_token_static -m 10 -C -G -c -t -D < \
$(srcdir)/crypto/proposal/proposal_keywords_static.txt > $@
+if STATIC_PLUGIN_CONSTRUCTORS
+BUILT_SOURCES += $(srcdir)/plugin_constructors.c
+CLEANFILES = $(srcdir)/plugin_constructors.c
+
+$(srcdir)/plugin_constructors.c: $(srcdir)/plugins/plugin_constructors.py
+ $(AM_V_GEN) \
+ $(PYTHON) $(srcdir)/plugins/plugin_constructors.py ${s_plugins} > $@
+endif
+
if MONOLITHIC
SUBDIRS =
else
diff --git a/src/libstrongswan/Makefile.in b/src/libstrongswan/Makefile.in
index 99bb1158c..9b1c26b35 100644
--- a/src/libstrongswan/Makefile.in
+++ b/src/libstrongswan/Makefile.in
@@ -123,128 +123,129 @@ host_triplet = @host@
@USE_BUILTIN_PRINTF_TRUE@am__append_15 = -lm
@USE_BUILTIN_PRINTF_FALSE@@USE_VSTR_FALSE@am__append_16 = utils/printf_hook/printf_hook_glibc.c
@USE_LIBCAP_TRUE@am__append_17 = -lcap
+@STATIC_PLUGIN_CONSTRUCTORS_TRUE@am__append_18 = $(srcdir)/plugin_constructors.c
# build libnttfft used by some plugins
######################################
-@USE_LIBNTTFFT_TRUE@am__append_18 = math/libnttfft
+@USE_LIBNTTFFT_TRUE@am__append_19 = math/libnttfft
# build plugins with their own Makefile
#######################################
-@USE_AF_ALG_TRUE@am__append_19 = plugins/af_alg
-@MONOLITHIC_TRUE@@USE_AF_ALG_TRUE@am__append_20 = plugins/af_alg/libstrongswan-af-alg.la
-@USE_AES_TRUE@am__append_21 = plugins/aes
-@MONOLITHIC_TRUE@@USE_AES_TRUE@am__append_22 = plugins/aes/libstrongswan-aes.la
-@USE_DES_TRUE@am__append_23 = plugins/des
-@MONOLITHIC_TRUE@@USE_DES_TRUE@am__append_24 = plugins/des/libstrongswan-des.la
-@USE_BLOWFISH_TRUE@am__append_25 = plugins/blowfish
-@MONOLITHIC_TRUE@@USE_BLOWFISH_TRUE@am__append_26 = plugins/blowfish/libstrongswan-blowfish.la
-@USE_RC2_TRUE@am__append_27 = plugins/rc2
-@MONOLITHIC_TRUE@@USE_RC2_TRUE@am__append_28 = plugins/rc2/libstrongswan-rc2.la
-@USE_MD4_TRUE@am__append_29 = plugins/md4
-@MONOLITHIC_TRUE@@USE_MD4_TRUE@am__append_30 = plugins/md4/libstrongswan-md4.la
-@USE_MD5_TRUE@am__append_31 = plugins/md5
-@MONOLITHIC_TRUE@@USE_MD5_TRUE@am__append_32 = plugins/md5/libstrongswan-md5.la
-@USE_SHA1_TRUE@am__append_33 = plugins/sha1
-@MONOLITHIC_TRUE@@USE_SHA1_TRUE@am__append_34 = plugins/sha1/libstrongswan-sha1.la
-@USE_SHA2_TRUE@am__append_35 = plugins/sha2
-@MONOLITHIC_TRUE@@USE_SHA2_TRUE@am__append_36 = plugins/sha2/libstrongswan-sha2.la
-@USE_SHA3_TRUE@am__append_37 = plugins/sha3
-@MONOLITHIC_TRUE@@USE_SHA3_TRUE@am__append_38 = plugins/sha3/libstrongswan-sha3.la
-@USE_GMP_TRUE@am__append_39 = plugins/gmp
-@MONOLITHIC_TRUE@@USE_GMP_TRUE@am__append_40 = plugins/gmp/libstrongswan-gmp.la
-@USE_CURVE25519_TRUE@am__append_41 = plugins/curve25519
-@MONOLITHIC_TRUE@@USE_CURVE25519_TRUE@am__append_42 = plugins/curve25519/libstrongswan-curve25519.la
-@USE_RDRAND_TRUE@am__append_43 = plugins/rdrand
-@MONOLITHIC_TRUE@@USE_RDRAND_TRUE@am__append_44 = plugins/rdrand/libstrongswan-rdrand.la
-@USE_AESNI_TRUE@am__append_45 = plugins/aesni
-@MONOLITHIC_TRUE@@USE_AESNI_TRUE@am__append_46 = plugins/aesni/libstrongswan-aesni.la
-@USE_RANDOM_TRUE@am__append_47 = plugins/random
-@MONOLITHIC_TRUE@@USE_RANDOM_TRUE@am__append_48 = plugins/random/libstrongswan-random.la
-@USE_NONCE_TRUE@am__append_49 = plugins/nonce
-@MONOLITHIC_TRUE@@USE_NONCE_TRUE@am__append_50 = plugins/nonce/libstrongswan-nonce.la
-@USE_HMAC_TRUE@am__append_51 = plugins/hmac
-@MONOLITHIC_TRUE@@USE_HMAC_TRUE@am__append_52 = plugins/hmac/libstrongswan-hmac.la
-@USE_CMAC_TRUE@am__append_53 = plugins/cmac
-@MONOLITHIC_TRUE@@USE_CMAC_TRUE@am__append_54 = plugins/cmac/libstrongswan-cmac.la
-@USE_XCBC_TRUE@am__append_55 = plugins/xcbc
-@MONOLITHIC_TRUE@@USE_XCBC_TRUE@am__append_56 = plugins/xcbc/libstrongswan-xcbc.la
-@USE_X509_TRUE@am__append_57 = plugins/x509
-@MONOLITHIC_TRUE@@USE_X509_TRUE@am__append_58 = plugins/x509/libstrongswan-x509.la
-@USE_REVOCATION_TRUE@am__append_59 = plugins/revocation
-@MONOLITHIC_TRUE@@USE_REVOCATION_TRUE@am__append_60 = plugins/revocation/libstrongswan-revocation.la
-@USE_CONSTRAINTS_TRUE@am__append_61 = plugins/constraints
-@MONOLITHIC_TRUE@@USE_CONSTRAINTS_TRUE@am__append_62 = plugins/constraints/libstrongswan-constraints.la
-@USE_ACERT_TRUE@am__append_63 = plugins/acert
-@MONOLITHIC_TRUE@@USE_ACERT_TRUE@am__append_64 = plugins/acert/libstrongswan-acert.la
-@USE_PUBKEY_TRUE@am__append_65 = plugins/pubkey
-@MONOLITHIC_TRUE@@USE_PUBKEY_TRUE@am__append_66 = plugins/pubkey/libstrongswan-pubkey.la
-@USE_PKCS1_TRUE@am__append_67 = plugins/pkcs1
-@MONOLITHIC_TRUE@@USE_PKCS1_TRUE@am__append_68 = plugins/pkcs1/libstrongswan-pkcs1.la
-@USE_PKCS7_TRUE@am__append_69 = plugins/pkcs7
-@MONOLITHIC_TRUE@@USE_PKCS7_TRUE@am__append_70 = plugins/pkcs7/libstrongswan-pkcs7.la
-@USE_PKCS8_TRUE@am__append_71 = plugins/pkcs8
-@MONOLITHIC_TRUE@@USE_PKCS8_TRUE@am__append_72 = plugins/pkcs8/libstrongswan-pkcs8.la
-@USE_PKCS12_TRUE@am__append_73 = plugins/pkcs12
-@MONOLITHIC_TRUE@@USE_PKCS12_TRUE@am__append_74 = plugins/pkcs12/libstrongswan-pkcs12.la
-@USE_PGP_TRUE@am__append_75 = plugins/pgp
-@MONOLITHIC_TRUE@@USE_PGP_TRUE@am__append_76 = plugins/pgp/libstrongswan-pgp.la
-@USE_DNSKEY_TRUE@am__append_77 = plugins/dnskey
-@MONOLITHIC_TRUE@@USE_DNSKEY_TRUE@am__append_78 = plugins/dnskey/libstrongswan-dnskey.la
-@USE_SSHKEY_TRUE@am__append_79 = plugins/sshkey
-@MONOLITHIC_TRUE@@USE_SSHKEY_TRUE@am__append_80 = plugins/sshkey/libstrongswan-sshkey.la
-@USE_PEM_TRUE@am__append_81 = plugins/pem
-@MONOLITHIC_TRUE@@USE_PEM_TRUE@am__append_82 = plugins/pem/libstrongswan-pem.la
-@USE_CURL_TRUE@am__append_83 = plugins/curl
-@MONOLITHIC_TRUE@@USE_CURL_TRUE@am__append_84 = plugins/curl/libstrongswan-curl.la
-@USE_FILES_TRUE@am__append_85 = plugins/files
-@MONOLITHIC_TRUE@@USE_FILES_TRUE@am__append_86 = plugins/files/libstrongswan-files.la
-@USE_WINHTTP_TRUE@am__append_87 = plugins/winhttp
-@MONOLITHIC_TRUE@@USE_WINHTTP_TRUE@am__append_88 = plugins/winhttp/libstrongswan-winhttp.la
-@USE_UNBOUND_TRUE@am__append_89 = plugins/unbound
-@MONOLITHIC_TRUE@@USE_UNBOUND_TRUE@am__append_90 = plugins/unbound/libstrongswan-unbound.la
-@USE_SOUP_TRUE@am__append_91 = plugins/soup
-@MONOLITHIC_TRUE@@USE_SOUP_TRUE@am__append_92 = plugins/soup/libstrongswan-soup.la
-@USE_LDAP_TRUE@am__append_93 = plugins/ldap
-@MONOLITHIC_TRUE@@USE_LDAP_TRUE@am__append_94 = plugins/ldap/libstrongswan-ldap.la
-@USE_MYSQL_TRUE@am__append_95 = plugins/mysql
-@MONOLITHIC_TRUE@@USE_MYSQL_TRUE@am__append_96 = plugins/mysql/libstrongswan-mysql.la
-@USE_SQLITE_TRUE@am__append_97 = plugins/sqlite
-@MONOLITHIC_TRUE@@USE_SQLITE_TRUE@am__append_98 = plugins/sqlite/libstrongswan-sqlite.la
-@USE_PADLOCK_TRUE@am__append_99 = plugins/padlock
-@MONOLITHIC_TRUE@@USE_PADLOCK_TRUE@am__append_100 = plugins/padlock/libstrongswan-padlock.la
-@USE_OPENSSL_TRUE@am__append_101 = plugins/openssl
-@MONOLITHIC_TRUE@@USE_OPENSSL_TRUE@am__append_102 = plugins/openssl/libstrongswan-openssl.la
-@USE_GCRYPT_TRUE@am__append_103 = plugins/gcrypt
-@MONOLITHIC_TRUE@@USE_GCRYPT_TRUE@am__append_104 = plugins/gcrypt/libstrongswan-gcrypt.la
-@USE_FIPS_PRF_TRUE@am__append_105 = plugins/fips_prf
-@MONOLITHIC_TRUE@@USE_FIPS_PRF_TRUE@am__append_106 = plugins/fips_prf/libstrongswan-fips-prf.la
-@USE_AGENT_TRUE@am__append_107 = plugins/agent
-@MONOLITHIC_TRUE@@USE_AGENT_TRUE@am__append_108 = plugins/agent/libstrongswan-agent.la
-@USE_KEYCHAIN_TRUE@am__append_109 = plugins/keychain
-@MONOLITHIC_TRUE@@USE_KEYCHAIN_TRUE@am__append_110 = plugins/keychain/libstrongswan-keychain.la
-@USE_PKCS11_TRUE@am__append_111 = plugins/pkcs11
-@MONOLITHIC_TRUE@@USE_PKCS11_TRUE@am__append_112 = plugins/pkcs11/libstrongswan-pkcs11.la
-@USE_CHAPOLY_TRUE@am__append_113 = plugins/chapoly
-@MONOLITHIC_TRUE@@USE_CHAPOLY_TRUE@am__append_114 = plugins/chapoly/libstrongswan-chapoly.la
-@USE_CTR_TRUE@am__append_115 = plugins/ctr
-@MONOLITHIC_TRUE@@USE_CTR_TRUE@am__append_116 = plugins/ctr/libstrongswan-ctr.la
-@USE_CCM_TRUE@am__append_117 = plugins/ccm
-@MONOLITHIC_TRUE@@USE_CCM_TRUE@am__append_118 = plugins/ccm/libstrongswan-ccm.la
-@USE_GCM_TRUE@am__append_119 = plugins/gcm
-@MONOLITHIC_TRUE@@USE_GCM_TRUE@am__append_120 = plugins/gcm/libstrongswan-gcm.la
-@USE_MGF1_TRUE@am__append_121 = plugins/mgf1
-@MONOLITHIC_TRUE@@USE_MGF1_TRUE@am__append_122 = plugins/mgf1/libstrongswan-mgf1.la
-@USE_NTRU_TRUE@am__append_123 = plugins/ntru
-@MONOLITHIC_TRUE@@USE_NTRU_TRUE@am__append_124 = plugins/ntru/libstrongswan-ntru.la
-@USE_BLISS_TRUE@am__append_125 = plugins/bliss
-@MONOLITHIC_TRUE@@USE_BLISS_TRUE@am__append_126 = plugins/bliss/libstrongswan-bliss.la
-@USE_NEWHOPE_TRUE@am__append_127 = plugins/newhope
-@MONOLITHIC_TRUE@@USE_NEWHOPE_TRUE@am__append_128 = plugins/newhope/libstrongswan-newhope.la
-@USE_TEST_VECTORS_TRUE@am__append_129 = plugins/test_vectors
-@MONOLITHIC_TRUE@@USE_TEST_VECTORS_TRUE@am__append_130 = plugins/test_vectors/libstrongswan-test-vectors.la
-@USE_LIBNTTFFT_TRUE@am__append_131 = math/libnttfft/tests
-@USE_BLISS_TRUE@am__append_132 = plugins/bliss/tests
-@USE_NEWHOPE_TRUE@am__append_133 = plugins/newhope/tests
+@USE_AF_ALG_TRUE@am__append_20 = plugins/af_alg
+@MONOLITHIC_TRUE@@USE_AF_ALG_TRUE@am__append_21 = plugins/af_alg/libstrongswan-af-alg.la
+@USE_AES_TRUE@am__append_22 = plugins/aes
+@MONOLITHIC_TRUE@@USE_AES_TRUE@am__append_23 = plugins/aes/libstrongswan-aes.la
+@USE_DES_TRUE@am__append_24 = plugins/des
+@MONOLITHIC_TRUE@@USE_DES_TRUE@am__append_25 = plugins/des/libstrongswan-des.la
+@USE_BLOWFISH_TRUE@am__append_26 = plugins/blowfish
+@MONOLITHIC_TRUE@@USE_BLOWFISH_TRUE@am__append_27 = plugins/blowfish/libstrongswan-blowfish.la
+@USE_RC2_TRUE@am__append_28 = plugins/rc2
+@MONOLITHIC_TRUE@@USE_RC2_TRUE@am__append_29 = plugins/rc2/libstrongswan-rc2.la
+@USE_MD4_TRUE@am__append_30 = plugins/md4
+@MONOLITHIC_TRUE@@USE_MD4_TRUE@am__append_31 = plugins/md4/libstrongswan-md4.la
+@USE_MD5_TRUE@am__append_32 = plugins/md5
+@MONOLITHIC_TRUE@@USE_MD5_TRUE@am__append_33 = plugins/md5/libstrongswan-md5.la
+@USE_SHA1_TRUE@am__append_34 = plugins/sha1
+@MONOLITHIC_TRUE@@USE_SHA1_TRUE@am__append_35 = plugins/sha1/libstrongswan-sha1.la
+@USE_SHA2_TRUE@am__append_36 = plugins/sha2
+@MONOLITHIC_TRUE@@USE_SHA2_TRUE@am__append_37 = plugins/sha2/libstrongswan-sha2.la
+@USE_SHA3_TRUE@am__append_38 = plugins/sha3
+@MONOLITHIC_TRUE@@USE_SHA3_TRUE@am__append_39 = plugins/sha3/libstrongswan-sha3.la
+@USE_GMP_TRUE@am__append_40 = plugins/gmp
+@MONOLITHIC_TRUE@@USE_GMP_TRUE@am__append_41 = plugins/gmp/libstrongswan-gmp.la
+@USE_CURVE25519_TRUE@am__append_42 = plugins/curve25519
+@MONOLITHIC_TRUE@@USE_CURVE25519_TRUE@am__append_43 = plugins/curve25519/libstrongswan-curve25519.la
+@USE_RDRAND_TRUE@am__append_44 = plugins/rdrand
+@MONOLITHIC_TRUE@@USE_RDRAND_TRUE@am__append_45 = plugins/rdrand/libstrongswan-rdrand.la
+@USE_AESNI_TRUE@am__append_46 = plugins/aesni
+@MONOLITHIC_TRUE@@USE_AESNI_TRUE@am__append_47 = plugins/aesni/libstrongswan-aesni.la
+@USE_RANDOM_TRUE@am__append_48 = plugins/random
+@MONOLITHIC_TRUE@@USE_RANDOM_TRUE@am__append_49 = plugins/random/libstrongswan-random.la
+@USE_NONCE_TRUE@am__append_50 = plugins/nonce
+@MONOLITHIC_TRUE@@USE_NONCE_TRUE@am__append_51 = plugins/nonce/libstrongswan-nonce.la
+@USE_HMAC_TRUE@am__append_52 = plugins/hmac
+@MONOLITHIC_TRUE@@USE_HMAC_TRUE@am__append_53 = plugins/hmac/libstrongswan-hmac.la
+@USE_CMAC_TRUE@am__append_54 = plugins/cmac
+@MONOLITHIC_TRUE@@USE_CMAC_TRUE@am__append_55 = plugins/cmac/libstrongswan-cmac.la
+@USE_XCBC_TRUE@am__append_56 = plugins/xcbc
+@MONOLITHIC_TRUE@@USE_XCBC_TRUE@am__append_57 = plugins/xcbc/libstrongswan-xcbc.la
+@USE_X509_TRUE@am__append_58 = plugins/x509
+@MONOLITHIC_TRUE@@USE_X509_TRUE@am__append_59 = plugins/x509/libstrongswan-x509.la
+@USE_REVOCATION_TRUE@am__append_60 = plugins/revocation
+@MONOLITHIC_TRUE@@USE_REVOCATION_TRUE@am__append_61 = plugins/revocation/libstrongswan-revocation.la
+@USE_CONSTRAINTS_TRUE@am__append_62 = plugins/constraints
+@MONOLITHIC_TRUE@@USE_CONSTRAINTS_TRUE@am__append_63 = plugins/constraints/libstrongswan-constraints.la
+@USE_ACERT_TRUE@am__append_64 = plugins/acert
+@MONOLITHIC_TRUE@@USE_ACERT_TRUE@am__append_65 = plugins/acert/libstrongswan-acert.la
+@USE_PUBKEY_TRUE@am__append_66 = plugins/pubkey
+@MONOLITHIC_TRUE@@USE_PUBKEY_TRUE@am__append_67 = plugins/pubkey/libstrongswan-pubkey.la
+@USE_PKCS1_TRUE@am__append_68 = plugins/pkcs1
+@MONOLITHIC_TRUE@@USE_PKCS1_TRUE@am__append_69 = plugins/pkcs1/libstrongswan-pkcs1.la
+@USE_PKCS7_TRUE@am__append_70 = plugins/pkcs7
+@MONOLITHIC_TRUE@@USE_PKCS7_TRUE@am__append_71 = plugins/pkcs7/libstrongswan-pkcs7.la
+@USE_PKCS8_TRUE@am__append_72 = plugins/pkcs8
+@MONOLITHIC_TRUE@@USE_PKCS8_TRUE@am__append_73 = plugins/pkcs8/libstrongswan-pkcs8.la
+@USE_PKCS12_TRUE@am__append_74 = plugins/pkcs12
+@MONOLITHIC_TRUE@@USE_PKCS12_TRUE@am__append_75 = plugins/pkcs12/libstrongswan-pkcs12.la
+@USE_PGP_TRUE@am__append_76 = plugins/pgp
+@MONOLITHIC_TRUE@@USE_PGP_TRUE@am__append_77 = plugins/pgp/libstrongswan-pgp.la
+@USE_DNSKEY_TRUE@am__append_78 = plugins/dnskey
+@MONOLITHIC_TRUE@@USE_DNSKEY_TRUE@am__append_79 = plugins/dnskey/libstrongswan-dnskey.la
+@USE_SSHKEY_TRUE@am__append_80 = plugins/sshkey
+@MONOLITHIC_TRUE@@USE_SSHKEY_TRUE@am__append_81 = plugins/sshkey/libstrongswan-sshkey.la
+@USE_PEM_TRUE@am__append_82 = plugins/pem
+@MONOLITHIC_TRUE@@USE_PEM_TRUE@am__append_83 = plugins/pem/libstrongswan-pem.la
+@USE_CURL_TRUE@am__append_84 = plugins/curl
+@MONOLITHIC_TRUE@@USE_CURL_TRUE@am__append_85 = plugins/curl/libstrongswan-curl.la
+@USE_FILES_TRUE@am__append_86 = plugins/files
+@MONOLITHIC_TRUE@@USE_FILES_TRUE@am__append_87 = plugins/files/libstrongswan-files.la
+@USE_WINHTTP_TRUE@am__append_88 = plugins/winhttp
+@MONOLITHIC_TRUE@@USE_WINHTTP_TRUE@am__append_89 = plugins/winhttp/libstrongswan-winhttp.la
+@USE_UNBOUND_TRUE@am__append_90 = plugins/unbound
+@MONOLITHIC_TRUE@@USE_UNBOUND_TRUE@am__append_91 = plugins/unbound/libstrongswan-unbound.la
+@USE_SOUP_TRUE@am__append_92 = plugins/soup
+@MONOLITHIC_TRUE@@USE_SOUP_TRUE@am__append_93 = plugins/soup/libstrongswan-soup.la
+@USE_LDAP_TRUE@am__append_94 = plugins/ldap
+@MONOLITHIC_TRUE@@USE_LDAP_TRUE@am__append_95 = plugins/ldap/libstrongswan-ldap.la
+@USE_MYSQL_TRUE@am__append_96 = plugins/mysql
+@MONOLITHIC_TRUE@@USE_MYSQL_TRUE@am__append_97 = plugins/mysql/libstrongswan-mysql.la
+@USE_SQLITE_TRUE@am__append_98 = plugins/sqlite
+@MONOLITHIC_TRUE@@USE_SQLITE_TRUE@am__append_99 = plugins/sqlite/libstrongswan-sqlite.la
+@USE_PADLOCK_TRUE@am__append_100 = plugins/padlock
+@MONOLITHIC_TRUE@@USE_PADLOCK_TRUE@am__append_101 = plugins/padlock/libstrongswan-padlock.la
+@USE_OPENSSL_TRUE@am__append_102 = plugins/openssl
+@MONOLITHIC_TRUE@@USE_OPENSSL_TRUE@am__append_103 = plugins/openssl/libstrongswan-openssl.la
+@USE_GCRYPT_TRUE@am__append_104 = plugins/gcrypt
+@MONOLITHIC_TRUE@@USE_GCRYPT_TRUE@am__append_105 = plugins/gcrypt/libstrongswan-gcrypt.la
+@USE_FIPS_PRF_TRUE@am__append_106 = plugins/fips_prf
+@MONOLITHIC_TRUE@@USE_FIPS_PRF_TRUE@am__append_107 = plugins/fips_prf/libstrongswan-fips-prf.la
+@USE_AGENT_TRUE@am__append_108 = plugins/agent
+@MONOLITHIC_TRUE@@USE_AGENT_TRUE@am__append_109 = plugins/agent/libstrongswan-agent.la
+@USE_KEYCHAIN_TRUE@am__append_110 = plugins/keychain
+@MONOLITHIC_TRUE@@USE_KEYCHAIN_TRUE@am__append_111 = plugins/keychain/libstrongswan-keychain.la
+@USE_PKCS11_TRUE@am__append_112 = plugins/pkcs11
+@MONOLITHIC_TRUE@@USE_PKCS11_TRUE@am__append_113 = plugins/pkcs11/libstrongswan-pkcs11.la
+@USE_CHAPOLY_TRUE@am__append_114 = plugins/chapoly
+@MONOLITHIC_TRUE@@USE_CHAPOLY_TRUE@am__append_115 = plugins/chapoly/libstrongswan-chapoly.la
+@USE_CTR_TRUE@am__append_116 = plugins/ctr
+@MONOLITHIC_TRUE@@USE_CTR_TRUE@am__append_117 = plugins/ctr/libstrongswan-ctr.la
+@USE_CCM_TRUE@am__append_118 = plugins/ccm
+@MONOLITHIC_TRUE@@USE_CCM_TRUE@am__append_119 = plugins/ccm/libstrongswan-ccm.la
+@USE_GCM_TRUE@am__append_120 = plugins/gcm
+@MONOLITHIC_TRUE@@USE_GCM_TRUE@am__append_121 = plugins/gcm/libstrongswan-gcm.la
+@USE_MGF1_TRUE@am__append_122 = plugins/mgf1
+@MONOLITHIC_TRUE@@USE_MGF1_TRUE@am__append_123 = plugins/mgf1/libstrongswan-mgf1.la
+@USE_NTRU_TRUE@am__append_124 = plugins/ntru
+@MONOLITHIC_TRUE@@USE_NTRU_TRUE@am__append_125 = plugins/ntru/libstrongswan-ntru.la
+@USE_BLISS_TRUE@am__append_126 = plugins/bliss
+@MONOLITHIC_TRUE@@USE_BLISS_TRUE@am__append_127 = plugins/bliss/libstrongswan-bliss.la
+@USE_NEWHOPE_TRUE@am__append_128 = plugins/newhope
+@MONOLITHIC_TRUE@@USE_NEWHOPE_TRUE@am__append_129 = plugins/newhope/libstrongswan-newhope.la
+@USE_TEST_VECTORS_TRUE@am__append_130 = plugins/test_vectors
+@MONOLITHIC_TRUE@@USE_TEST_VECTORS_TRUE@am__append_131 = plugins/test_vectors/libstrongswan-test-vectors.la
+@USE_LIBNTTFFT_TRUE@am__append_132 = math/libnttfft/tests
+@USE_BLISS_TRUE@am__append_133 = plugins/bliss/tests
+@USE_NEWHOPE_TRUE@am__append_134 = plugins/newhope/tests
subdir = src/libstrongswan
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
@@ -304,26 +305,26 @@ libstrongswan_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_20) \
- $(am__append_22) $(am__append_24) $(am__append_26) \
- $(am__append_28) $(am__append_30) $(am__append_32) \
- $(am__append_34) $(am__append_36) $(am__append_38) \
- $(am__append_40) $(am__append_42) $(am__append_44) \
- $(am__append_46) $(am__append_48) $(am__append_50) \
- $(am__append_52) $(am__append_54) $(am__append_56) \
- $(am__append_58) $(am__append_60) $(am__append_62) \
- $(am__append_64) $(am__append_66) $(am__append_68) \
- $(am__append_70) $(am__append_72) $(am__append_74) \
- $(am__append_76) $(am__append_78) $(am__append_80) \
- $(am__append_82) $(am__append_84) $(am__append_86) \
- $(am__append_88) $(am__append_90) $(am__append_92) \
- $(am__append_94) $(am__append_96) $(am__append_98) \
- $(am__append_100) $(am__append_102) $(am__append_104) \
- $(am__append_106) $(am__append_108) $(am__append_110) \
- $(am__append_112) $(am__append_114) $(am__append_116) \
- $(am__append_118) $(am__append_120) $(am__append_122) \
- $(am__append_124) $(am__append_126) $(am__append_128) \
- $(am__append_130)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_21) \
+ $(am__append_23) $(am__append_25) $(am__append_27) \
+ $(am__append_29) $(am__append_31) $(am__append_33) \
+ $(am__append_35) $(am__append_37) $(am__append_39) \
+ $(am__append_41) $(am__append_43) $(am__append_45) \
+ $(am__append_47) $(am__append_49) $(am__append_51) \
+ $(am__append_53) $(am__append_55) $(am__append_57) \
+ $(am__append_59) $(am__append_61) $(am__append_63) \
+ $(am__append_65) $(am__append_67) $(am__append_69) \
+ $(am__append_71) $(am__append_73) $(am__append_75) \
+ $(am__append_77) $(am__append_79) $(am__append_81) \
+ $(am__append_83) $(am__append_85) $(am__append_87) \
+ $(am__append_89) $(am__append_91) $(am__append_93) \
+ $(am__append_95) $(am__append_97) $(am__append_99) \
+ $(am__append_101) $(am__append_103) $(am__append_105) \
+ $(am__append_107) $(am__append_109) $(am__append_111) \
+ $(am__append_113) $(am__append_115) $(am__append_117) \
+ $(am__append_119) $(am__append_121) $(am__append_123) \
+ $(am__append_125) $(am__append_127) $(am__append_129) \
+ $(am__append_131)
am__libstrongswan_la_SOURCES_DIST = library.c asn1/asn1.c \
asn1/asn1_parser.c asn1/oid.c bio/bio_reader.c \
bio/bio_writer.c collections/blocking_queue.c \
@@ -830,6 +831,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -852,6 +854,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
@@ -1037,26 +1040,26 @@ settings/settings_types.h
libstrongswan_la_LIBADD = $(DLLIB) $(ATOMICLIB) $(BTLIB) $(SOCKLIB) \
$(RTLIB) $(BFDLIB) $(UNWINDLIB) $(am__append_2) \
$(am__append_4) $(am__append_5) $(am__append_13) \
- $(am__append_15) $(am__append_17) $(am__append_20) \
- $(am__append_22) $(am__append_24) $(am__append_26) \
- $(am__append_28) $(am__append_30) $(am__append_32) \
- $(am__append_34) $(am__append_36) $(am__append_38) \
- $(am__append_40) $(am__append_42) $(am__append_44) \
- $(am__append_46) $(am__append_48) $(am__append_50) \
- $(am__append_52) $(am__append_54) $(am__append_56) \
- $(am__append_58) $(am__append_60) $(am__append_62) \
- $(am__append_64) $(am__append_66) $(am__append_68) \
- $(am__append_70) $(am__append_72) $(am__append_74) \
- $(am__append_76) $(am__append_78) $(am__append_80) \
- $(am__append_82) $(am__append_84) $(am__append_86) \
- $(am__append_88) $(am__append_90) $(am__append_92) \
- $(am__append_94) $(am__append_96) $(am__append_98) \
- $(am__append_100) $(am__append_102) $(am__append_104) \
- $(am__append_106) $(am__append_108) $(am__append_110) \
- $(am__append_112) $(am__append_114) $(am__append_116) \
- $(am__append_118) $(am__append_120) $(am__append_122) \
- $(am__append_124) $(am__append_126) $(am__append_128) \
- $(am__append_130)
+ $(am__append_15) $(am__append_17) $(am__append_21) \
+ $(am__append_23) $(am__append_25) $(am__append_27) \
+ $(am__append_29) $(am__append_31) $(am__append_33) \
+ $(am__append_35) $(am__append_37) $(am__append_39) \
+ $(am__append_41) $(am__append_43) $(am__append_45) \
+ $(am__append_47) $(am__append_49) $(am__append_51) \
+ $(am__append_53) $(am__append_55) $(am__append_57) \
+ $(am__append_59) $(am__append_61) $(am__append_63) \
+ $(am__append_65) $(am__append_67) $(am__append_69) \
+ $(am__append_71) $(am__append_73) $(am__append_75) \
+ $(am__append_77) $(am__append_79) $(am__append_81) \
+ $(am__append_83) $(am__append_85) $(am__append_87) \
+ $(am__append_89) $(am__append_91) $(am__append_93) \
+ $(am__append_95) $(am__append_97) $(am__append_99) \
+ $(am__append_101) $(am__append_103) $(am__append_105) \
+ $(am__append_107) $(am__append_109) $(am__append_111) \
+ $(am__append_113) $(am__append_115) $(am__append_117) \
+ $(am__append_119) $(am__append_121) $(am__append_123) \
+ $(am__append_125) $(am__append_127) $(am__append_129) \
+ $(am__append_131)
AM_CPPFLAGS = -I$(top_srcdir)/src/libstrongswan \
-DIPSEC_DIR=\"${ipsecdir}\" -DIPSEC_LIB_DIR=\"${ipseclibdir}\" \
-DPLUGINDIR=\"${plugindir}\" \
@@ -1072,83 +1075,83 @@ AM_YFLAGS = -v -d
EXTRA_DIST = \
asn1/oid.txt asn1/oid.pl \
crypto/proposal/proposal_keywords_static.txt \
+plugins/plugin_constructors.py \
Android.mk
-BUILT_SOURCES = \
-$(srcdir)/asn1/oid.c $(srcdir)/asn1/oid.h \
-$(srcdir)/crypto/proposal/proposal_keywords_static.c \
-settings/settings_parser.h
-
+BUILT_SOURCES = $(srcdir)/asn1/oid.c $(srcdir)/asn1/oid.h \
+ $(srcdir)/crypto/proposal/proposal_keywords_static.c \
+ settings/settings_parser.h $(am__append_18)
MAINTAINERCLEANFILES = \
$(srcdir)/asn1/oid.c $(srcdir)/asn1/oid.h \
$(srcdir)/crypto/proposal/proposal_keywords_static.c
+@STATIC_PLUGIN_CONSTRUCTORS_TRUE@CLEANFILES = $(srcdir)/plugin_constructors.c
# build unit tests
##################
-@MONOLITHIC_FALSE@SUBDIRS = . $(am__append_18) $(am__append_19) \
-@MONOLITHIC_FALSE@ $(am__append_21) $(am__append_23) \
-@MONOLITHIC_FALSE@ $(am__append_25) $(am__append_27) \
-@MONOLITHIC_FALSE@ $(am__append_29) $(am__append_31) \
-@MONOLITHIC_FALSE@ $(am__append_33) $(am__append_35) \
-@MONOLITHIC_FALSE@ $(am__append_37) $(am__append_39) \
-@MONOLITHIC_FALSE@ $(am__append_41) $(am__append_43) \
-@MONOLITHIC_FALSE@ $(am__append_45) $(am__append_47) \
-@MONOLITHIC_FALSE@ $(am__append_49) $(am__append_51) \
-@MONOLITHIC_FALSE@ $(am__append_53) $(am__append_55) \
-@MONOLITHIC_FALSE@ $(am__append_57) $(am__append_59) \
-@MONOLITHIC_FALSE@ $(am__append_61) $(am__append_63) \
-@MONOLITHIC_FALSE@ $(am__append_65) $(am__append_67) \
-@MONOLITHIC_FALSE@ $(am__append_69) $(am__append_71) \
-@MONOLITHIC_FALSE@ $(am__append_73) $(am__append_75) \
-@MONOLITHIC_FALSE@ $(am__append_77) $(am__append_79) \
-@MONOLITHIC_FALSE@ $(am__append_81) $(am__append_83) \
-@MONOLITHIC_FALSE@ $(am__append_85) $(am__append_87) \
-@MONOLITHIC_FALSE@ $(am__append_89) $(am__append_91) \
-@MONOLITHIC_FALSE@ $(am__append_93) $(am__append_95) \
-@MONOLITHIC_FALSE@ $(am__append_97) $(am__append_99) \
-@MONOLITHIC_FALSE@ $(am__append_101) $(am__append_103) \
-@MONOLITHIC_FALSE@ $(am__append_105) $(am__append_107) \
-@MONOLITHIC_FALSE@ $(am__append_109) $(am__append_111) \
-@MONOLITHIC_FALSE@ $(am__append_113) $(am__append_115) \
-@MONOLITHIC_FALSE@ $(am__append_117) $(am__append_119) \
-@MONOLITHIC_FALSE@ $(am__append_121) $(am__append_123) \
-@MONOLITHIC_FALSE@ $(am__append_125) $(am__append_127) \
-@MONOLITHIC_FALSE@ $(am__append_129) tests $(am__append_131) \
-@MONOLITHIC_FALSE@ $(am__append_132) $(am__append_133)
+@MONOLITHIC_FALSE@SUBDIRS = . $(am__append_19) $(am__append_20) \
+@MONOLITHIC_FALSE@ $(am__append_22) $(am__append_24) \
+@MONOLITHIC_FALSE@ $(am__append_26) $(am__append_28) \
+@MONOLITHIC_FALSE@ $(am__append_30) $(am__append_32) \
+@MONOLITHIC_FALSE@ $(am__append_34) $(am__append_36) \
+@MONOLITHIC_FALSE@ $(am__append_38) $(am__append_40) \
+@MONOLITHIC_FALSE@ $(am__append_42) $(am__append_44) \
+@MONOLITHIC_FALSE@ $(am__append_46) $(am__append_48) \
+@MONOLITHIC_FALSE@ $(am__append_50) $(am__append_52) \
+@MONOLITHIC_FALSE@ $(am__append_54) $(am__append_56) \
+@MONOLITHIC_FALSE@ $(am__append_58) $(am__append_60) \
+@MONOLITHIC_FALSE@ $(am__append_62) $(am__append_64) \
+@MONOLITHIC_FALSE@ $(am__append_66) $(am__append_68) \
+@MONOLITHIC_FALSE@ $(am__append_70) $(am__append_72) \
+@MONOLITHIC_FALSE@ $(am__append_74) $(am__append_76) \
+@MONOLITHIC_FALSE@ $(am__append_78) $(am__append_80) \
+@MONOLITHIC_FALSE@ $(am__append_82) $(am__append_84) \
+@MONOLITHIC_FALSE@ $(am__append_86) $(am__append_88) \
+@MONOLITHIC_FALSE@ $(am__append_90) $(am__append_92) \
+@MONOLITHIC_FALSE@ $(am__append_94) $(am__append_96) \
+@MONOLITHIC_FALSE@ $(am__append_98) $(am__append_100) \
+@MONOLITHIC_FALSE@ $(am__append_102) $(am__append_104) \
+@MONOLITHIC_FALSE@ $(am__append_106) $(am__append_108) \
+@MONOLITHIC_FALSE@ $(am__append_110) $(am__append_112) \
+@MONOLITHIC_FALSE@ $(am__append_114) $(am__append_116) \
+@MONOLITHIC_FALSE@ $(am__append_118) $(am__append_120) \
+@MONOLITHIC_FALSE@ $(am__append_122) $(am__append_124) \
+@MONOLITHIC_FALSE@ $(am__append_126) $(am__append_128) \
+@MONOLITHIC_FALSE@ $(am__append_130) tests $(am__append_132) \
+@MONOLITHIC_FALSE@ $(am__append_133) $(am__append_134)
# build unit tests
##################
-@MONOLITHIC_TRUE@SUBDIRS = $(am__append_18) $(am__append_19) \
-@MONOLITHIC_TRUE@ $(am__append_21) $(am__append_23) \
-@MONOLITHIC_TRUE@ $(am__append_25) $(am__append_27) \
-@MONOLITHIC_TRUE@ $(am__append_29) $(am__append_31) \
-@MONOLITHIC_TRUE@ $(am__append_33) $(am__append_35) \
-@MONOLITHIC_TRUE@ $(am__append_37) $(am__append_39) \
-@MONOLITHIC_TRUE@ $(am__append_41) $(am__append_43) \
-@MONOLITHIC_TRUE@ $(am__append_45) $(am__append_47) \
-@MONOLITHIC_TRUE@ $(am__append_49) $(am__append_51) \
-@MONOLITHIC_TRUE@ $(am__append_53) $(am__append_55) \
-@MONOLITHIC_TRUE@ $(am__append_57) $(am__append_59) \
-@MONOLITHIC_TRUE@ $(am__append_61) $(am__append_63) \
-@MONOLITHIC_TRUE@ $(am__append_65) $(am__append_67) \
-@MONOLITHIC_TRUE@ $(am__append_69) $(am__append_71) \
-@MONOLITHIC_TRUE@ $(am__append_73) $(am__append_75) \
-@MONOLITHIC_TRUE@ $(am__append_77) $(am__append_79) \
-@MONOLITHIC_TRUE@ $(am__append_81) $(am__append_83) \
-@MONOLITHIC_TRUE@ $(am__append_85) $(am__append_87) \
-@MONOLITHIC_TRUE@ $(am__append_89) $(am__append_91) \
-@MONOLITHIC_TRUE@ $(am__append_93) $(am__append_95) \
-@MONOLITHIC_TRUE@ $(am__append_97) $(am__append_99) \
-@MONOLITHIC_TRUE@ $(am__append_101) $(am__append_103) \
-@MONOLITHIC_TRUE@ $(am__append_105) $(am__append_107) \
-@MONOLITHIC_TRUE@ $(am__append_109) $(am__append_111) \
-@MONOLITHIC_TRUE@ $(am__append_113) $(am__append_115) \
-@MONOLITHIC_TRUE@ $(am__append_117) $(am__append_119) \
-@MONOLITHIC_TRUE@ $(am__append_121) $(am__append_123) \
-@MONOLITHIC_TRUE@ $(am__append_125) $(am__append_127) \
-@MONOLITHIC_TRUE@ $(am__append_129) . tests $(am__append_131) \
-@MONOLITHIC_TRUE@ $(am__append_132) $(am__append_133)
+@MONOLITHIC_TRUE@SUBDIRS = $(am__append_19) $(am__append_20) \
+@MONOLITHIC_TRUE@ $(am__append_22) $(am__append_24) \
+@MONOLITHIC_TRUE@ $(am__append_26) $(am__append_28) \
+@MONOLITHIC_TRUE@ $(am__append_30) $(am__append_32) \
+@MONOLITHIC_TRUE@ $(am__append_34) $(am__append_36) \
+@MONOLITHIC_TRUE@ $(am__append_38) $(am__append_40) \
+@MONOLITHIC_TRUE@ $(am__append_42) $(am__append_44) \
+@MONOLITHIC_TRUE@ $(am__append_46) $(am__append_48) \
+@MONOLITHIC_TRUE@ $(am__append_50) $(am__append_52) \
+@MONOLITHIC_TRUE@ $(am__append_54) $(am__append_56) \
+@MONOLITHIC_TRUE@ $(am__append_58) $(am__append_60) \
+@MONOLITHIC_TRUE@ $(am__append_62) $(am__append_64) \
+@MONOLITHIC_TRUE@ $(am__append_66) $(am__append_68) \
+@MONOLITHIC_TRUE@ $(am__append_70) $(am__append_72) \
+@MONOLITHIC_TRUE@ $(am__append_74) $(am__append_76) \
+@MONOLITHIC_TRUE@ $(am__append_78) $(am__append_80) \
+@MONOLITHIC_TRUE@ $(am__append_82) $(am__append_84) \
+@MONOLITHIC_TRUE@ $(am__append_86) $(am__append_88) \
+@MONOLITHIC_TRUE@ $(am__append_90) $(am__append_92) \
+@MONOLITHIC_TRUE@ $(am__append_94) $(am__append_96) \
+@MONOLITHIC_TRUE@ $(am__append_98) $(am__append_100) \
+@MONOLITHIC_TRUE@ $(am__append_102) $(am__append_104) \
+@MONOLITHIC_TRUE@ $(am__append_106) $(am__append_108) \
+@MONOLITHIC_TRUE@ $(am__append_110) $(am__append_112) \
+@MONOLITHIC_TRUE@ $(am__append_114) $(am__append_116) \
+@MONOLITHIC_TRUE@ $(am__append_118) $(am__append_120) \
+@MONOLITHIC_TRUE@ $(am__append_122) $(am__append_124) \
+@MONOLITHIC_TRUE@ $(am__append_126) $(am__append_128) \
+@MONOLITHIC_TRUE@ $(am__append_130) . tests $(am__append_132) \
+@MONOLITHIC_TRUE@ $(am__append_133) $(am__append_134)
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-recursive
@@ -2184,6 +2187,7 @@ install-strip:
mostlyclean-generic:
clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
@@ -2382,6 +2386,10 @@ $(srcdir)/crypto/proposal/proposal_keywords_static.c: $(srcdir)/crypto/proposal/
$(GPERF) -N proposal_get_token_static -m 10 -C -G -c -t -D < \
$(srcdir)/crypto/proposal/proposal_keywords_static.txt > $@
+@STATIC_PLUGIN_CONSTRUCTORS_TRUE@$(srcdir)/plugin_constructors.c: $(srcdir)/plugins/plugin_constructors.py
+@STATIC_PLUGIN_CONSTRUCTORS_TRUE@ $(AM_V_GEN) \
+@STATIC_PLUGIN_CONSTRUCTORS_TRUE@ $(PYTHON) $(srcdir)/plugins/plugin_constructors.py ${s_plugins} > $@
+
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/src/libstrongswan/asn1/asn1.c b/src/libstrongswan/asn1/asn1.c
index 5ce840325..8b9dc1c48 100644
--- a/src/libstrongswan/asn1/asn1.c
+++ b/src/libstrongswan/asn1/asn1.c
@@ -350,13 +350,15 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
int tm_leap_4, tm_leap_100, tm_leap_400, tm_leap;
int tz_hour, tz_min, tz_offset;
time_t tm_days, tm_secs;
- u_char *eot = NULL;
+ char buf[BUF_LEN], *eot = NULL;
- if ((eot = memchr(utctime->ptr, 'Z', utctime->len)) != NULL)
+ snprintf(buf, sizeof(buf), "%.*s", (int)utctime->len, utctime->ptr);
+
+ if ((eot = strchr(buf, 'Z')) != NULL)
{
tz_offset = 0; /* Zulu time with a zero time zone offset */
}
- else if ((eot = memchr(utctime->ptr, '+', utctime->len)) != NULL)
+ else if ((eot = strchr(buf, '+')) != NULL)
{
if (sscanf(eot+1, "%2d%2d", &tz_hour, &tz_min) != 2)
{
@@ -364,7 +366,7 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
}
tz_offset = 3600*tz_hour + 60*tz_min; /* positive time zone offset */
}
- else if ((eot = memchr(utctime->ptr, '-', utctime->len)) != NULL)
+ else if ((eot = strchr(buf, '-')) != NULL)
{
if (sscanf(eot+1, "%2d%2d", &tz_hour, &tz_min) != 2)
{
@@ -382,15 +384,15 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
const char* format = (type == ASN1_UTCTIME)? "%2d%2d%2d%2d%2d":
"%4d%2d%2d%2d%2d";
- if (sscanf(utctime->ptr, format, &tm_year, &tm_mon, &tm_day,
- &tm_hour, &tm_min) != 5)
+ if (sscanf(buf, format, &tm_year, &tm_mon, &tm_day,
+ &tm_hour, &tm_min) != 5)
{
return 0; /* error in [yy]yymmddhhmm time format */
}
}
/* is there a seconds field? */
- if ((eot - utctime->ptr) == ((type == ASN1_UTCTIME)?12:14))
+ if ((eot - buf) == ((type == ASN1_UTCTIME)?12:14))
{
if (sscanf(eot-2, "%2d", &tm_sec) != 1)
{
diff --git a/src/libstrongswan/asn1/asn1_parser.c b/src/libstrongswan/asn1/asn1_parser.c
index e7b7a428d..4d5f799b7 100644
--- a/src/libstrongswan/asn1/asn1_parser.c
+++ b/src/libstrongswan/asn1/asn1_parser.c
@@ -1,8 +1,7 @@
/*
* Copyright (C) 2006 Martin Will
- * Copyright (C) 2000-2008 Andreas Steffen
- *
- * Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2000-2017 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -76,12 +75,18 @@ struct private_asn1_parser_t {
* Current parsing pointer for each level
*/
chunk_t blobs[ASN1_MAX_LEVEL + 2];
+
+ /**
+ * Parsing a CHOICE on the current level ?
+ */
+ bool choice[ASN1_MAX_LEVEL + 2];
+
};
METHOD(asn1_parser_t, iterate, bool,
private_asn1_parser_t *this, int *objectID, chunk_t *object)
{
- chunk_t *blob, *blob1;
+ chunk_t *blob, *blob1, blob_ori;
u_char *start_ptr;
u_int level;
asn1Object_t obj;
@@ -97,7 +102,7 @@ METHOD(asn1_parser_t, iterate, bool,
return FALSE;
}
- if (obj.flags & ASN1_END) /* end of loop or option found */
+ if (obj.flags & ASN1_END) /* end of loop or choice or option found */
{
if (this->loopAddr[obj.level] && this->blobs[obj.level+1].len > 0)
{
@@ -106,13 +111,42 @@ METHOD(asn1_parser_t, iterate, bool,
}
else
{
- this->loopAddr[obj.level] = 0; /* exit loop or option*/
+ this->loopAddr[obj.level] = 0; /* exit loop */
+
+ if (obj.flags & ASN1_CHOICE) /* end of choices */
+ {
+ if (this->choice[obj.level+1])
+ {
+ DBG1(DBG_ASN, "L%d - %s: incorrect choice encoding",
+ this->level0 + obj.level, obj.name);
+ this->success = FALSE;
+ goto end;
+ }
+ }
+
+ if (obj.flags & ASN1_CH) /* end of choice */
+ {
+ /* parsed a valid choice */
+ this->choice[obj.level] = FALSE;
+
+ /* advance to end of choices */
+ do
+ {
+ this->line++;
+ }
+ while (!((this->objects[this->line].flags & ASN1_END) &&
+ (this->objects[this->line].flags & ASN1_CHOICE) &&
+ (this->objects[this->line].level == obj.level-1)));
+ this->line--;
+ }
+
goto end;
}
}
level = this->level0 + obj.level;
blob = this->blobs + obj.level;
+ blob_ori = *blob;
blob1 = blob + 1;
start_ptr = blob->ptr;
@@ -129,7 +163,6 @@ METHOD(asn1_parser_t, iterate, bool,
}
/* handle ASN.1 options */
-
if ((obj.flags & ASN1_OPT)
&& (blob->len == 0 || *start_ptr != obj.type))
{
@@ -144,7 +177,6 @@ METHOD(asn1_parser_t, iterate, bool,
}
/* an ASN.1 object must possess at least a tag and length field */
-
if (blob->len < 2)
{
DBG1(DBG_ASN, "L%d - %s: ASN.1 object smaller than 2 octets",
@@ -167,8 +199,16 @@ METHOD(asn1_parser_t, iterate, bool,
blob->ptr += blob1->len;
blob->len -= blob1->len;
- /* return raw ASN.1 object without prior type checking */
+ /* handle ASN.1 choice without explicit context encoding */
+ if ((obj.flags & ASN1_CHOICE) && obj.type == ASN1_EOC)
+ {
+ DBG2(DBG_ASN, "L%d - %s:", level, obj.name);
+ this->choice[obj.level+1] = TRUE;
+ *blob1 = blob_ori;
+ goto end;
+ }
+ /* return raw ASN.1 object without prior type checking */
if (obj.flags & ASN1_RAW)
{
DBG2(DBG_ASN, "L%d - %s:", level, obj.name);
@@ -209,6 +249,18 @@ METHOD(asn1_parser_t, iterate, bool,
}
}
+ /* In case of a "CHOICE" start to scan for exactly one valid choice */
+ if (obj.flags & ASN1_CHOICE)
+ {
+ if (blob1->len == 0)
+ {
+ DBG1(DBG_ASN, "L%d - %s: contains no choice", level, obj.name);
+ this->success = FALSE;
+ goto end;
+ }
+ this->choice[obj.level+1] = TRUE;
+ }
+
if (obj.flags & ASN1_OBJ)
{
object->ptr = start_ptr;
diff --git a/src/libstrongswan/asn1/asn1_parser.h b/src/libstrongswan/asn1/asn1_parser.h
index 0edc22c23..2ee1e892f 100644
--- a/src/libstrongswan/asn1/asn1_parser.h
+++ b/src/libstrongswan/asn1/asn1_parser.h
@@ -1,8 +1,7 @@
/*
* Copyright (C) 2006 Martin Will
- * Copyright (C) 2000-2008 Andreas Steffen
- *
- * Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2000-2017 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -32,15 +31,17 @@
/**
* Definition of ASN.1 flags
*/
-#define ASN1_NONE 0x00
-#define ASN1_DEF 0x01
-#define ASN1_OPT 0x02
-#define ASN1_LOOP 0x04
-#define ASN1_END 0x08
-#define ASN1_OBJ 0x10
-#define ASN1_BODY 0x20
-#define ASN1_RAW 0x40
-#define ASN1_EXIT 0x80
+#define ASN1_NONE 0x0000
+#define ASN1_DEF 0x0001
+#define ASN1_OPT 0x0002
+#define ASN1_LOOP 0x0004
+#define ASN1_CHOICE 0x0008
+#define ASN1_CH 0x0010
+#define ASN1_END 0x0020
+#define ASN1_OBJ 0x0040
+#define ASN1_BODY 0x0080
+#define ASN1_RAW 0x0100
+#define ASN1_EXIT 0x0200
typedef struct asn1Object_t asn1Object_t;
@@ -51,7 +52,7 @@ struct asn1Object_t{
u_int level;
const u_char *name;
asn1_t type;
- u_char flags;
+ uint16_t flags;
};
typedef struct asn1_parser_t asn1_parser_t;
diff --git a/src/libstrongswan/collections/array.c b/src/libstrongswan/collections/array.c
index 69e7df99e..c3dd6e0e9 100644
--- a/src/libstrongswan/collections/array.c
+++ b/src/libstrongswan/collections/array.c
@@ -214,9 +214,11 @@ typedef struct {
} array_enumerator_t;
METHOD(enumerator_t, enumerate, bool,
- array_enumerator_t *this, void **out)
+ array_enumerator_t *this, va_list args)
{
- void *pos;
+ void *pos, **out;
+
+ VA_ARGS_VGET(args, out);
if (this->idx >= this->array->count)
{
@@ -250,7 +252,8 @@ enumerator_t* array_create_enumerator(array_t *array)
INIT(enumerator,
.public = {
- .enumerate = (void*)_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate,
.destroy = (void*)free,
},
.array = array,
diff --git a/src/libstrongswan/collections/enumerator.c b/src/libstrongswan/collections/enumerator.c
index fa277e7c8..52c9e1cd5 100644
--- a/src/libstrongswan/collections/enumerator.c
+++ b/src/libstrongswan/collections/enumerator.c
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2008-2013 Tobias Brunner
+ * Copyright (C) 2008-2017 Tobias Brunner
* Copyright (C) 2007 Martin Willi
- * Hochschule fuer Technik Rapperswil
+ * HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -31,22 +31,43 @@
#include <utils/debug.h>
-/**
- * Implementation of enumerator_create_empty().enumerate
+/*
+ * Described in header.
*/
-static bool enumerate_empty(enumerator_t *enumerator, ...)
+bool enumerator_enumerate_default(enumerator_t *enumerator, ...)
+{
+ va_list args;
+ bool result;
+
+ if (!enumerator->venumerate)
+ {
+ DBG1(DBG_LIB, "!!! ENUMERATE DEFAULT: venumerate() missing !!!");
+ return FALSE;
+ }
+ va_start(args, enumerator);
+ result = enumerator->venumerate(enumerator, args);
+ va_end(args);
+ return result;
+}
+
+METHOD(enumerator_t, enumerate_empty, bool,
+ enumerator_t *enumerator, va_list args)
{
return FALSE;
}
-/**
- * See header
+/*
+ * Described in header
*/
enumerator_t* enumerator_create_empty()
{
- enumerator_t *this = malloc_thing(enumerator_t);
- this->enumerate = enumerate_empty;
- this->destroy = (void*)free;
+ enumerator_t *this;
+
+ INIT(this,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate_empty,
+ .destroy = (void*)free,
+ );
return this;
}
@@ -64,32 +85,31 @@ typedef struct {
char *full_end;
} dir_enum_t;
-/**
- * Implementation of enumerator_create_directory().destroy
- */
-static void destroy_dir_enum(dir_enum_t *this)
+METHOD(enumerator_t, destroy_dir_enum, void,
+ dir_enum_t *this)
{
closedir(this->dir);
free(this);
}
-/**
- * Implementation of enumerator_create_directory().enumerate
- */
-static bool enumerate_dir_enum(dir_enum_t *this, char **relative,
- char **absolute, struct stat *st)
+METHOD(enumerator_t, enumerate_dir_enum, bool,
+ dir_enum_t *this, va_list args)
{
struct dirent *entry = readdir(this->dir);
+ struct stat *st;
size_t remaining;
+ char **relative, **absolute;
int len;
+ VA_ARGS_VGET(args, relative, absolute, st);
+
if (!entry)
{
return FALSE;
}
if (streq(entry->d_name, ".") || streq(entry->d_name, ".."))
{
- return enumerate_dir_enum(this, relative, absolute, st);
+ return this->public.enumerate(&this->public, relative, absolute, st);
}
if (relative)
{
@@ -122,15 +142,21 @@ static bool enumerate_dir_enum(dir_enum_t *this, char **relative,
return TRUE;
}
-/**
- * See header
+/*
+ * Described in header
*/
enumerator_t* enumerator_create_directory(const char *path)
{
+ dir_enum_t *this;
int len;
- dir_enum_t *this = malloc_thing(dir_enum_t);
- this->public.enumerate = (void*)enumerate_dir_enum;
- this->public.destroy = (void*)destroy_dir_enum;
+
+ INIT(this,
+ .public = {
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate_dir_enum,
+ .destroy = _destroy_dir_enum,
+ },
+ );
if (*path == '\0')
{
@@ -152,9 +178,10 @@ enumerator_t* enumerator_create_directory(const char *path)
this->full_end = &this->full[len];
this->dir = opendir(path);
- if (this->dir == NULL)
+ if (!this->dir)
{
- DBG1(DBG_LIB, "opening directory '%s' failed: %s", path, strerror(errno));
+ DBG1(DBG_LIB, "opening directory '%s' failed: %s", path,
+ strerror(errno));
free(this);
return NULL;
}
@@ -177,21 +204,21 @@ typedef struct {
char full[PATH_MAX];
} glob_enum_t;
-/**
- * Implementation of enumerator_create_glob().destroy
- */
-static void destroy_glob_enum(glob_enum_t *this)
+METHOD(enumerator_t, destroy_glob_enum, void,
+ glob_enum_t *this)
{
globfree(&this->glob);
free(this);
}
-/**
- * Implementation of enumerator_create_glob().enumerate
- */
-static bool enumerate_glob_enum(glob_enum_t *this, char **file, struct stat *st)
+METHOD(enumerator_t, enumerate_glob_enum, bool,
+ glob_enum_t *this, va_list args)
{
+ struct stat *st;
char *match;
+ char **file;
+
+ VA_ARGS_VGET(args, file, st);
if (this->pos >= this->glob.gl_pathc)
{
@@ -202,20 +229,17 @@ static bool enumerate_glob_enum(glob_enum_t *this, char **file, struct stat *st)
{
*file = match;
}
- if (st)
+ if (st && stat(match, st))
{
- if (stat(match, st))
- {
- DBG1(DBG_LIB, "stat() on '%s' failed: %s", match,
- strerror(errno));
- return FALSE;
- }
+ DBG1(DBG_LIB, "stat() on '%s' failed: %s", match,
+ strerror(errno));
+ return FALSE;
}
return TRUE;
}
-/**
- * See header
+/*
+ * Described in header
*/
enumerator_t* enumerator_create_glob(const char *pattern)
{
@@ -229,8 +253,9 @@ enumerator_t* enumerator_create_glob(const char *pattern)
INIT(this,
.public = {
- .enumerate = (void*)enumerate_glob_enum,
- .destroy = (void*)destroy_glob_enum,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate_glob_enum,
+ .destroy = _destroy_glob_enum,
},
);
@@ -272,24 +297,22 @@ typedef struct {
const char *trim;
} token_enum_t;
-/**
- * Implementation of enumerator_create_token().destroy
- */
-static void destroy_token_enum(token_enum_t *this)
+METHOD(enumerator_t, destroy_token_enum, void,
+ token_enum_t *this)
{
free(this->string);
free(this);
}
-/**
- * Implementation of enumerator_create_token().enumerate
- */
-static bool enumerate_token_enum(token_enum_t *this, char **token)
+METHOD(enumerator_t, enumerate_token_enum, bool,
+ token_enum_t *this, va_list args)
{
const char *sep, *trim;
- char *pos = NULL, *tmp;
+ char *pos = NULL, *tmp, **token;
bool last = FALSE;
+ VA_ARGS_VGET(args, token);
+
/* trim leading characters/separators */
while (*this->pos)
{
@@ -390,52 +413,48 @@ static bool enumerate_token_enum(token_enum_t *this, char **token)
return FALSE;
}
-/**
- * See header
+/*
+ * Described in header
*/
enumerator_t* enumerator_create_token(const char *string, const char *sep,
const char *trim)
{
- token_enum_t *enumerator = malloc_thing(token_enum_t);
+ token_enum_t *this;
- enumerator->public.enumerate = (void*)enumerate_token_enum;
- enumerator->public.destroy = (void*)destroy_token_enum;
- enumerator->string = strdup(string);
- enumerator->pos = enumerator->string;
- enumerator->sep = sep;
- enumerator->trim = trim;
+ INIT(this,
+ .public = {
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate_token_enum,
+ .destroy = _destroy_token_enum,
+ },
+ .string = strdup(string),
+ .sep = sep,
+ .trim = trim,
+ );
+ this->pos = this->string;
- return &enumerator->public;
+ return &this->public;
}
/**
- * enumerator for nested enumerations
+ * Enumerator for nested enumerations
*/
typedef struct {
- /* implements enumerator_t */
enumerator_t public;
- /* outer enumerator */
enumerator_t *outer;
- /* inner enumerator */
enumerator_t *inner;
- /* constructor for inner enumerator */
enumerator_t *(*create_inner)(void *outer, void *data);
- /* data to pass to constructor above */
void *data;
- /* destructor for data */
- void (*destroy_data)(void *data);
+ void (*destructor)(void *data);
} nested_enumerator_t;
-/**
- * Implementation of enumerator_create_nested().enumerate()
- */
-static bool enumerate_nested(nested_enumerator_t *this, void *v1, void *v2,
- void *v3, void *v4, void *v5)
+METHOD(enumerator_t, enumerate_nested, bool,
+ nested_enumerator_t *this, va_list args)
{
while (TRUE)
{
- while (this->inner == NULL)
+ while (!this->inner)
{
void *outer;
@@ -444,8 +463,13 @@ static bool enumerate_nested(nested_enumerator_t *this, void *v1, void *v2,
return FALSE;
}
this->inner = this->create_inner(outer, this->data);
+ if (this->inner && !this->inner->venumerate)
+ {
+ DBG1(DBG_LIB, "!!! ENUMERATE NESTED: venumerate() missing !!!");
+ return FALSE;
+ }
}
- if (this->inner->enumerate(this->inner, v1, v2, v3, v4, v5))
+ if (this->inner->venumerate(this->inner, args))
{
return TRUE;
}
@@ -454,103 +478,100 @@ static bool enumerate_nested(nested_enumerator_t *this, void *v1, void *v2,
}
}
-/**
- * Implementation of enumerator_create_nested().destroy()
- **/
-static void destroy_nested(nested_enumerator_t *this)
+METHOD(enumerator_t, destroy_nested, void,
+ nested_enumerator_t *this)
{
- if (this->destroy_data)
+ if (this->destructor)
{
- this->destroy_data(this->data);
+ this->destructor(this->data);
}
DESTROY_IF(this->inner);
this->outer->destroy(this->outer);
free(this);
}
-/**
- * See header
+/*
+ * Described in header
*/
enumerator_t *enumerator_create_nested(enumerator_t *outer,
enumerator_t *(inner_constructor)(void *outer, void *data),
- void *data, void (*destroy_data)(void *data))
+ void *data, void (*destructor)(void *data))
{
- nested_enumerator_t *enumerator = malloc_thing(nested_enumerator_t);
+ nested_enumerator_t *this;
- enumerator->public.enumerate = (void*)enumerate_nested;
- enumerator->public.destroy = (void*)destroy_nested;
- enumerator->outer = outer;
- enumerator->inner = NULL;
- enumerator->create_inner = (void*)inner_constructor;
- enumerator->data = data;
- enumerator->destroy_data = destroy_data;
-
- return &enumerator->public;
+ INIT(this,
+ .public = {
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate_nested,
+ .destroy = _destroy_nested,
+ },
+ .outer = outer,
+ .create_inner = inner_constructor,
+ .data = data,
+ .destructor = destructor,
+ );
+ return &this->public;
}
/**
- * enumerator for filtered enumerator
+ * Enumerator for filtered enumerator
*/
typedef struct {
enumerator_t public;
- enumerator_t *unfiltered;
+ enumerator_t *orig;
void *data;
- bool (*filter)(void *data, ...);
+ bool (*filter)(void*,enumerator_t*,va_list);
void (*destructor)(void *data);
} filter_enumerator_t;
-/**
- * Implementation of enumerator_create_filter().destroy
- */
-static void destroy_filter(filter_enumerator_t *this)
+METHOD(enumerator_t, destroy_filter, void,
+ filter_enumerator_t *this)
{
if (this->destructor)
{
this->destructor(this->data);
}
- this->unfiltered->destroy(this->unfiltered);
+ this->orig->destroy(this->orig);
free(this);
}
-/**
- * Implementation of enumerator_create_filter().enumerate
- */
-static bool enumerate_filter(filter_enumerator_t *this, void *o1, void *o2,
- void *o3, void *o4, void *o5)
+METHOD(enumerator_t, enumerate_filter, bool,
+ filter_enumerator_t *this, va_list args)
{
- void *i1, *i2, *i3, *i4, *i5;
+ bool result = FALSE;
- while (this->unfiltered->enumerate(this->unfiltered, &i1, &i2, &i3, &i4, &i5))
+ if (this->filter(this->data, this->orig, args))
{
- if (this->filter(this->data, &i1, o1, &i2, o2, &i3, o3, &i4, o4, &i5, o5))
- {
- return TRUE;
- }
+ result = TRUE;
}
- return FALSE;
+ return result;
}
-/**
- * see header
+/*
+ * Described in header
*/
-enumerator_t *enumerator_create_filter(enumerator_t *unfiltered,
- bool (*filter)(void *data, ...),
- void *data, void (*destructor)(void *data))
+enumerator_t *enumerator_create_filter(enumerator_t *orig,
+ bool (*filter)(void *data, enumerator_t *orig, va_list args),
+ void *data, void (*destructor)(void *data))
{
- filter_enumerator_t *this = malloc_thing(filter_enumerator_t);
-
- this->public.enumerate = (void*)enumerate_filter;
- this->public.destroy = (void*)destroy_filter;
- this->unfiltered = unfiltered;
- this->filter = filter;
- this->data = data;
- this->destructor = destructor;
+ filter_enumerator_t *this;
+ INIT(this,
+ .public = {
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate_filter,
+ .destroy = _destroy_filter,
+ },
+ .orig = orig,
+ .filter = filter,
+ .data = data,
+ .destructor = destructor,
+ );
return &this->public;
}
/**
- * enumerator for cleaner enumerator
+ * Enumerator for cleaner enumerator
*/
typedef struct {
enumerator_t public;
@@ -559,44 +580,48 @@ typedef struct {
void *data;
} cleaner_enumerator_t;
-/**
- * Implementation of enumerator_create_cleanup().destroy
- */
-static void destroy_cleaner(cleaner_enumerator_t *this)
+METHOD(enumerator_t, destroy_cleaner, void,
+ cleaner_enumerator_t *this)
{
this->cleanup(this->data);
this->wrapped->destroy(this->wrapped);
free(this);
}
-/**
- * Implementation of enumerator_create_cleaner().enumerate
- */
-static bool enumerate_cleaner(cleaner_enumerator_t *this, void *v1, void *v2,
- void *v3, void *v4, void *v5)
+METHOD(enumerator_t, enumerate_cleaner, bool,
+ cleaner_enumerator_t *this, va_list args)
{
- return this->wrapped->enumerate(this->wrapped, v1, v2, v3, v4, v5);
+ if (!this->wrapped->venumerate)
+ {
+ DBG1(DBG_LIB, "!!! CLEANER ENUMERATOR: venumerate() missing !!!");
+ return FALSE;
+ }
+ return this->wrapped->venumerate(this->wrapped, args);
}
-/**
- * see header
+/*
+ * Described in header
*/
enumerator_t *enumerator_create_cleaner(enumerator_t *wrapped,
void (*cleanup)(void *data), void *data)
{
- cleaner_enumerator_t *this = malloc_thing(cleaner_enumerator_t);
-
- this->public.enumerate = (void*)enumerate_cleaner;
- this->public.destroy = (void*)destroy_cleaner;
- this->wrapped = wrapped;
- this->cleanup = cleanup;
- this->data = data;
+ cleaner_enumerator_t *this;
+ INIT(this,
+ .public = {
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate_cleaner,
+ .destroy = _destroy_cleaner,
+ },
+ .wrapped = wrapped,
+ .cleanup = cleanup,
+ .data = data,
+ );
return &this->public;
}
/**
- * enumerator for single enumerator
+ * Enumerator for single enumerator
*/
typedef struct {
enumerator_t public;
@@ -605,10 +630,8 @@ typedef struct {
bool done;
} single_enumerator_t;
-/**
- * Implementation of enumerator_create_single().destroy
- */
-static void destroy_single(single_enumerator_t *this)
+METHOD(enumerator_t, destroy_single, void,
+ single_enumerator_t *this)
{
if (this->cleanup)
{
@@ -617,11 +640,12 @@ static void destroy_single(single_enumerator_t *this)
free(this);
}
-/**
- * Implementation of enumerator_create_single().enumerate
- */
-static bool enumerate_single(single_enumerator_t *this, void **item)
+METHOD(enumerator_t, enumerate_single, bool,
+ single_enumerator_t *this, va_list args)
{
+ void **item;
+
+ VA_ARGS_VGET(args, item);
if (this->done)
{
return FALSE;
@@ -631,19 +655,21 @@ static bool enumerate_single(single_enumerator_t *this, void **item)
return TRUE;
}
-/**
- * see header
+/*
+ * Described in header
*/
enumerator_t *enumerator_create_single(void *item, void (*cleanup)(void *item))
{
- single_enumerator_t *this = malloc_thing(single_enumerator_t);
-
- this->public.enumerate = (void*)enumerate_single;
- this->public.destroy = (void*)destroy_single;
- this->item = item;
- this->cleanup = cleanup;
- this->done = FALSE;
+ single_enumerator_t *this;
+ INIT(this,
+ .public = {
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate_single,
+ .destroy = _destroy_single,
+ },
+ .item = item,
+ .cleanup = cleanup,
+ );
return &this->public;
}
-
diff --git a/src/libstrongswan/collections/enumerator.h b/src/libstrongswan/collections/enumerator.h
index 55f8d83e6..99f8847e4 100644
--- a/src/libstrongswan/collections/enumerator.h
+++ b/src/libstrongswan/collections/enumerator.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2013 Tobias Brunner
+ * Copyright (C) 2013-2017 Tobias Brunner
* Copyright (C) 2007 Martin Willi
- * Hochschule fuer Technik Rapperswil
+ * HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -34,8 +34,11 @@ struct enumerator_t {
/**
* Enumerate collection.
*
- * The enumerate function takes a variable argument list containing
- * pointers where the enumerated values get written.
+ * The enumerate() method takes a variable number of pointer arguments
+ * where the enumerated values get written to.
+ *
+ * @note Just assigning the generic enumerator_enumerate_default() function
+ * that calls the enumerator's venumerate() method is usually enough.
*
* @param ... variable list of enumerated items, implementation dependent
* @return TRUE if pointers returned
@@ -43,12 +46,34 @@ struct enumerator_t {
bool (*enumerate)(enumerator_t *this, ...);
/**
- * Destroy a enumerator instance.
+ * Enumerate collection.
+ *
+ * The venumerate() method takes a variable argument list containing
+ * pointers where the enumerated values get written to.
+ *
+ * To simplify the implementation the VA_ARGS_VGET() macro may be used.
+ *
+ * @param args variable list of enumerated items, implementation dependent
+ * @return TRUE if pointers returned
+ */
+ bool (*venumerate)(enumerator_t *this, va_list args);
+
+ /**
+ * Destroy an enumerator_t instance.
*/
void (*destroy)(enumerator_t *this);
};
/**
+ * Generic implementation of enumerator_t::enumerate() that simply calls
+ * the enumerator's venumerate() method.
+ *
+ * @param enumerator the enumerator
+ * @param ... arguments passed to enumerate()
+ */
+bool enumerator_enumerate_default(enumerator_t *enumerator, ...);
+
+/**
* Create an enumerator which enumerates over nothing
*
* @return an enumerator over no values
@@ -147,38 +172,41 @@ enumerator_t* enumerator_create_token(const char *string, const char *sep,
/**
* Creates an enumerator which enumerates over enumerated enumerators :-).
*
- * The variable argument list of enumeration values is limit to 5.
+ * The outer enumerator is expected to return objects that, when passed to
+ * inner_contructor, will create a new enumerator that will be enumerated until
+ * completion (to this enumerator will the pointer arguments that are passed to
+ * this enumerator be forwarded) at which point a new element from the outer
+ * enumerator is requested to create a new inner enumerator.
*
* @param outer outer enumerator
- * @param inner_constructor constructor to inner enumerator
+ * @param inner_constructor constructor to create inner enumerator
* @param data data to pass to each inner_constructor call
- * @param destroy_data destructor to pass to data
+ * @param destructor destructor function to clean up data after use
* @return the nested enumerator
*/
enumerator_t *enumerator_create_nested(enumerator_t *outer,
enumerator_t *(*inner_constructor)(void *outer, void *data),
- void *data, void (*destroy_data)(void *data));
+ void *data, void (*destructor)(void *data));
/**
- * Creates an enumerator which filters output of another enumerator.
+ * Creates an enumerator which filters/maps output of another enumerator.
*
- * The filter function receives the user supplied "data" followed by a
- * unfiltered enumeration item, followed by an output pointer where to write
- * the filtered data. Then the next input/output pair follows.
- * It returns TRUE to deliver the
- * values to the caller of enumerate(), FALSE to filter this enumeration.
+ * The filter function receives the user supplied "data" followed by the
+ * original enumerator, followed by the arguments passed to the outer
+ * enumerator. It returns TRUE to deliver the values assigned to these
+ * arguments to the caller of enumerate() and FALSE to end the enumeration.
+ * Filtering items is simple as the filter function may just skip enumerated
+ * items from the original enumerator.
*
- * The variable argument list of enumeration values is limit to 5.
- *
- * @param unfiltered unfiltered enumerator to wrap, gets destroyed
+ * @param orig original enumerator to wrap, gets destroyed
* @param filter filter function
* @param data user data to supply to filter
* @param destructor destructor function to clean up data after use
* @return the filtered enumerator
*/
-enumerator_t *enumerator_create_filter(enumerator_t *unfiltered,
- bool (*filter)(void *data, ...),
- void *data, void (*destructor)(void *data));
+enumerator_t *enumerator_create_filter(enumerator_t *orig,
+ bool (*filter)(void *data, enumerator_t *orig, va_list args),
+ void *data, void (*destructor)(void *data));
/**
* Create an enumerator wrapper which does a cleanup on destroy.
diff --git a/src/libstrongswan/collections/hashtable.c b/src/libstrongswan/collections/hashtable.c
index 2b77a37cc..b0eda9e6a 100644
--- a/src/libstrongswan/collections/hashtable.c
+++ b/src/libstrongswan/collections/hashtable.c
@@ -379,8 +379,13 @@ METHOD(hashtable_t, get_count, u_int,
}
METHOD(enumerator_t, enumerate, bool,
- private_enumerator_t *this, const void **key, void **value)
+ private_enumerator_t *this, va_list args)
{
+ const void **key;
+ void **value;
+
+ VA_ARGS_VGET(args, key, value);
+
while (this->count && this->row < this->table->capacity)
{
this->prev = this->current;
@@ -417,7 +422,8 @@ METHOD(hashtable_t, create_enumerator, enumerator_t*,
INIT(enumerator,
.enumerator = {
- .enumerate = (void*)_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate,
.destroy = (void*)free,
},
.table = this,
diff --git a/src/libstrongswan/collections/linked_list.c b/src/libstrongswan/collections/linked_list.c
index b8fe81578..f877be5a6 100644
--- a/src/libstrongswan/collections/linked_list.c
+++ b/src/libstrongswan/collections/linked_list.c
@@ -47,6 +47,17 @@ struct element_t {
element_t *next;
};
+/*
+ * Described in header
+ */
+bool linked_list_match_str(void *item, va_list args)
+{
+ char *a = item, *b;
+
+ VA_ARGS_VGET(args, b);
+ return streq(a, b);
+}
+
/**
* Creates an empty linked list object.
*/
@@ -119,8 +130,12 @@ struct private_enumerator_t {
};
METHOD(enumerator_t, enumerate, bool,
- private_enumerator_t *this, void **item)
+ private_enumerator_t *this, va_list args)
{
+ void **item;
+
+ VA_ARGS_VGET(args, item);
+
if (this->finished)
{
return FALSE;
@@ -152,7 +167,8 @@ METHOD(linked_list_t, create_enumerator, enumerator_t*,
INIT(enumerator,
.enumerator = {
- .enumerate = (void*)_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate,
.destroy = (void*)free,
},
.list = this,
@@ -366,52 +382,68 @@ METHOD(linked_list_t, remove_at, void,
}
}
-METHOD(linked_list_t, find_first, status_t,
- private_linked_list_t *this, linked_list_match_t match,
- void **item, void *d1, void *d2, void *d3, void *d4, void *d5)
+METHOD(linked_list_t, find_first, bool,
+ private_linked_list_t *this, linked_list_match_t match, void **item, ...)
{
element_t *current = this->first;
+ va_list args;
+ bool matched = FALSE;
+
+ if (!match && !item)
+ {
+ return FALSE;
+ }
while (current)
{
- if ((match && match(current->value, d1, d2, d3, d4, d5)) ||
- (!match && item && current->value == *item))
+ if (match)
+ {
+ va_start(args, item);
+ matched = match(current->value, args);
+ va_end(args);
+ }
+ else
+ {
+ matched = current->value == *item;
+ }
+ if (matched)
{
if (item != NULL)
{
*item = current->value;
}
- return SUCCESS;
+ return TRUE;
}
current = current->next;
}
- return NOT_FOUND;
+ return FALSE;
}
METHOD(linked_list_t, invoke_offset, void,
- private_linked_list_t *this, size_t offset,
- void *d1, void *d2, void *d3, void *d4, void *d5)
+ private_linked_list_t *this, size_t offset)
{
element_t *current = this->first;
- linked_list_invoke_t *method;
+ void (**method)(void*);
while (current)
{
method = current->value + offset;
- (*method)(current->value, d1, d2, d3, d4, d5);
+ (*method)(current->value);
current = current->next;
}
}
METHOD(linked_list_t, invoke_function, void,
- private_linked_list_t *this, linked_list_invoke_t fn,
- void *d1, void *d2, void *d3, void *d4, void *d5)
+ private_linked_list_t *this, linked_list_invoke_t fn, ...)
{
element_t *current = this->first;
+ va_list args;
while (current)
{
- fn(current->value, d1, d2, d3, d4, d5);
+ va_start(args, fn);
+ fn(current->value, args);
+ va_end(args);
current = current->next;
}
}
@@ -542,7 +574,7 @@ linked_list_t *linked_list_create()
.reset_enumerator = (void*)_reset_enumerator,
.get_first = _get_first,
.get_last = _get_last,
- .find_first = (void*)_find_first,
+ .find_first = _find_first,
.insert_first = _insert_first,
.insert_last = _insert_last,
.insert_before = (void*)_insert_before,
@@ -550,8 +582,8 @@ linked_list_t *linked_list_create()
.remove_last = _remove_last,
.remove = _remove_,
.remove_at = (void*)_remove_at,
- .invoke_offset = (void*)_invoke_offset,
- .invoke_function = (void*)_invoke_function,
+ .invoke_offset = _invoke_offset,
+ .invoke_function = _invoke_function,
.clone_offset = _clone_offset,
.equals_offset = _equals_offset,
.equals_function = _equals_function,
diff --git a/src/libstrongswan/collections/linked_list.h b/src/libstrongswan/collections/linked_list.h
index 0b73079d3..246b9a5c5 100644
--- a/src/libstrongswan/collections/linked_list.h
+++ b/src/libstrongswan/collections/linked_list.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2015 Tobias Brunner
+ * Copyright (C) 2007-2017 Tobias Brunner
* Copyright (C) 2005-2008 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
@@ -28,23 +28,30 @@ typedef struct linked_list_t linked_list_t;
#include <collections/enumerator.h>
/**
- * Method to match elements in a linked list (used in find_* functions)
+ * Function to match elements in a linked list
*
* @param item current list item
- * @param ... user supplied data (only pointers, at most 5)
+ * @param args user supplied data
+ * @return TRUE, if the item matched, FALSE otherwise
+ */
+typedef bool (*linked_list_match_t)(void *item, va_list args);
+
+/**
+ * Helper function to match a string in a linked list of strings
+ *
+ * @param item list item (char*)
+ * @param args user supplied data (char*)
* @return
- * - TRUE, if the item matched
- * - FALSE, otherwise
*/
-typedef bool (*linked_list_match_t)(void *item, ...);
+bool linked_list_match_str(void *item, va_list args);
/**
- * Method to be invoked on elements in a linked list (used in invoke_* functions)
+ * Function to be invoked on elements in a linked list
*
* @param item current list item
- * @param ... user supplied data (only pointers, at most 5)
+ * @param args user supplied data
*/
-typedef void (*linked_list_invoke_t)(void *item, ...);
+typedef void (*linked_list_invoke_t)(void *item, va_list args);
/**
* Class implementing a double linked list.
@@ -167,21 +174,20 @@ struct linked_list_t {
*
* The first object passed to the match function is the current list item,
* followed by the user supplied data.
- * If the supplied function returns TRUE this function returns SUCCESS, and
- * the current object is returned in the third parameter, otherwise,
+ * If the supplied function returns TRUE so does this function, and the
+ * current object is returned in the third parameter (if given), otherwise,
* the next item is checked.
*
* If match is NULL, *item and the current object are compared.
*
- * @warning Only use pointers as user supplied data.
- *
* @param match comparison function to call on each object, or NULL
- * @param item the list item, if found
- * @param ... user data to supply to match function (limited to 5 arguments)
- * @return SUCCESS if found, NOT_FOUND otherwise
+ * @param item the list item, if found, or NULL
+ * @param ... user data to supply to match function
+ * @return TRUE if found, FALSE otherwise (or if neither match,
+ * nor item is supplied)
*/
- status_t (*find_first) (linked_list_t *this, linked_list_match_t match,
- void **item, ...);
+ bool (*find_first)(linked_list_t *this, linked_list_match_t match,
+ void **item, ...);
/**
* Invoke a method on all of the contained objects.
@@ -192,22 +198,18 @@ struct linked_list_t {
* which can be evalutated at compile time using the offsetof
* macro, e.g.: list->invoke(list, offsetof(object_t, method));
*
- * @warning Only use pointers as user supplied data.
- *
* @param offset offset of the method to invoke on objects
- * @param ... user data to supply to called function (limited to 5 arguments)
*/
- void (*invoke_offset) (linked_list_t *this, size_t offset, ...);
+ void (*invoke_offset)(linked_list_t *this, size_t offset);
/**
* Invoke a function on all of the contained objects.
*
- * @warning Only use pointers as user supplied data.
- *
- * @param function offset of the method to invoke on objects
- * @param ... user data to supply to called function (limited to 5 arguments)
+ * @param function function to call for each object
+ * @param ... user data to supply to called function
*/
- void (*invoke_function) (linked_list_t *this, linked_list_invoke_t function, ...);
+ void (*invoke_function)(linked_list_t *this, linked_list_invoke_t function,
+ ...);
/**
* Clones a list and its objects using the objects' clone method.
diff --git a/src/libstrongswan/credentials/auth_cfg.c b/src/libstrongswan/credentials/auth_cfg.c
index 8a3e659fd..a9c8b3904 100644
--- a/src/libstrongswan/credentials/auth_cfg.c
+++ b/src/libstrongswan/credentials/auth_cfg.c
@@ -146,12 +146,14 @@ typedef struct {
bool enumerated[AUTH_RULE_MAX];
} entry_enumerator_t;
-/**
- * enumerate function for item_enumerator_t
- */
-static bool enumerate(entry_enumerator_t *this, auth_rule_t *type, void **value)
+METHOD(enumerator_t, enumerate, bool,
+ entry_enumerator_t *this, va_list args)
{
+ auth_rule_t *type;
entry_t *entry;
+ void **value;
+
+ VA_ARGS_VGET(args, type, value);
while (this->inner->enumerate(this->inner, &entry))
{
@@ -174,10 +176,8 @@ static bool enumerate(entry_enumerator_t *this, auth_rule_t *type, void **value)
return FALSE;
}
-/**
- * destroy function for item_enumerator_t
- */
-static void entry_enumerator_destroy(entry_enumerator_t *this)
+METHOD(enumerator_t, entry_enumerator_destroy, void,
+ entry_enumerator_t *this)
{
this->inner->destroy(this->inner);
free(this);
@@ -190,8 +190,9 @@ METHOD(auth_cfg_t, create_enumerator, enumerator_t*,
INIT(enumerator,
.public = {
- .enumerate = (void*)enumerate,
- .destroy = (void*)entry_enumerator_destroy,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate,
+ .destroy = _entry_enumerator_destroy,
},
.inner = array_create_enumerator(this->entries),
);
diff --git a/src/libstrongswan/credentials/credential_factory.c b/src/libstrongswan/credentials/credential_factory.c
index 94c7820e1..07e6ea343 100644
--- a/src/libstrongswan/credentials/credential_factory.c
+++ b/src/libstrongswan/credentials/credential_factory.c
@@ -163,17 +163,23 @@ METHOD(credential_factory_t, create, void*,
return construct;
}
-/**
- * Filter function for builder enumerator
- */
-static bool builder_filter(void *null, entry_t **entry, credential_type_t *type,
- void *dummy1, int *subtype)
+CALLBACK(builder_filter, bool,
+ void *null, enumerator_t *orig, va_list args)
{
- if ((*entry)->final)
+ entry_t *entry;
+ credential_type_t *type;
+ int *subtype;
+
+ VA_ARGS_VGET(args, type, subtype);
+
+ while (orig->enumerate(orig, &entry))
{
- *type = (*entry)->type;
- *subtype = (*entry)->subtype;
- return TRUE;
+ if (entry->final)
+ {
+ *type = entry->type;
+ *subtype = entry->subtype;
+ return TRUE;
+ }
}
return FALSE;
}
@@ -184,7 +190,7 @@ METHOD(credential_factory_t, create_builder_enumerator, enumerator_t*,
this->lock->read_lock(this->lock);
return enumerator_create_filter(
this->constructors->create_enumerator(this->constructors),
- (void*)builder_filter, this->lock, (void*)this->lock->unlock);
+ builder_filter, this->lock, (void*)this->lock->unlock);
}
METHOD(credential_factory_t, destroy, void,
diff --git a/src/libstrongswan/credentials/credential_manager.c b/src/libstrongswan/credentials/credential_manager.c
index 95c5cd777..0a8d3d101 100644
--- a/src/libstrongswan/credentials/credential_manager.c
+++ b/src/libstrongswan/credentials/credential_manager.c
@@ -155,8 +155,12 @@ METHOD(credential_manager_t, call_hook, void,
}
METHOD(enumerator_t, sets_enumerate, bool,
- sets_enumerator_t *this, credential_set_t **set)
+ sets_enumerator_t *this, va_list args)
{
+ credential_set_t **set;
+
+ VA_ARGS_VGET(args, set);
+
if (this->exclusive)
{
if (this->exclusive->enumerate(this->exclusive, set))
@@ -166,19 +170,19 @@ METHOD(enumerator_t, sets_enumerate, bool,
return TRUE;
}
}
- if (this->global)
+ if (this->local)
{
- if (this->global->enumerate(this->global, set))
+ if (this->local->enumerate(this->local, set))
{
return TRUE;
}
- /* end of global sets, look for local */
- this->global->destroy(this->global);
- this->global = NULL;
+ /* end of local sets, look for global */
+ this->local->destroy(this->local);
+ this->local = NULL;
}
- if (this->local)
+ if (this->global)
{
- return this->local->enumerate(this->local, set);
+ return this->global->enumerate(this->global, set);
}
return FALSE;
}
@@ -202,7 +206,8 @@ static enumerator_t *create_sets_enumerator(private_credential_manager_t *this)
INIT(enumerator,
.public = {
- .enumerate = (void*)_sets_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _sets_enumerate,
.destroy = _sets_destroy,
},
);
@@ -807,11 +812,12 @@ static bool verify_trust_chain(private_credential_manager_t *this,
return trusted;
}
-/**
- * List find match function for certificates
- */
-static bool cert_equals(certificate_t *a, certificate_t *b)
+CALLBACK(cert_equals, bool,
+ certificate_t *a, va_list args)
{
+ certificate_t *b;
+
+ VA_ARGS_VGET(args, b);
return a->equals(a, b);
}
@@ -840,9 +846,12 @@ typedef struct {
} trusted_enumerator_t;
METHOD(enumerator_t, trusted_enumerate, bool,
- trusted_enumerator_t *this, certificate_t **cert, auth_cfg_t **auth)
+ trusted_enumerator_t *this, va_list args)
{
- certificate_t *current;
+ certificate_t *current, **cert;
+ auth_cfg_t **auth;
+
+ VA_ARGS_VGET(args, cert, auth);
DESTROY_IF(this->auth);
this->auth = auth_cfg_create();
@@ -888,8 +897,7 @@ METHOD(enumerator_t, trusted_enumerate, bool,
continue;
}
- if (this->failed->find_first(this->failed, (void*)cert_equals,
- NULL, current) == SUCCESS)
+ if (this->failed->find_first(this->failed, cert_equals, NULL, current))
{ /* check each candidate only once */
continue;
}
@@ -931,7 +939,8 @@ METHOD(credential_manager_t, create_trusted_enumerator, enumerator_t*,
INIT(enumerator,
.public = {
- .enumerate = (void*)_trusted_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _trusted_enumerate,
.destroy = _trusted_destroy,
},
.this = this,
@@ -960,9 +969,13 @@ typedef struct {
} public_enumerator_t;
METHOD(enumerator_t, public_enumerate, bool,
- public_enumerator_t *this, public_key_t **key, auth_cfg_t **auth)
+ public_enumerator_t *this, va_list args)
{
certificate_t *cert;
+ public_key_t **key;
+ auth_cfg_t **auth;
+
+ VA_ARGS_VGET(args, key, auth);
while (this->inner->enumerate(this->inner, &cert, auth))
{
@@ -1001,7 +1014,8 @@ METHOD(credential_manager_t, create_public_enumerator, enumerator_t*,
INIT(enumerator,
.public = {
- .enumerate = (void*)_public_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _public_enumerate,
.destroy = _public_destroy,
},
.inner = create_trusted_enumerator(this, type, id, online),
diff --git a/src/libstrongswan/credentials/keys/public_key.c b/src/libstrongswan/credentials/keys/public_key.c
index 2c76ad680..87f7e6664 100644
--- a/src/libstrongswan/credentials/keys/public_key.c
+++ b/src/libstrongswan/credentials/keys/public_key.c
@@ -272,8 +272,12 @@ typedef struct {
} private_enumerator_t;
METHOD(enumerator_t, signature_schemes_enumerate, bool,
- private_enumerator_t *this, signature_scheme_t *scheme)
+ private_enumerator_t *this, va_list args)
{
+ signature_scheme_t *scheme;
+
+ VA_ARGS_VGET(args, scheme);
+
while (++this->index < countof(scheme_map))
{
if (this->type == scheme_map[this->index].type &&
@@ -296,7 +300,8 @@ enumerator_t *signature_schemes_for_key(key_type_t type, int size)
INIT(this,
.public = {
- .enumerate = (void*)_signature_schemes_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _signature_schemes_enumerate,
.destroy = (void*)free,
},
.index = -1,
diff --git a/src/libstrongswan/credentials/sets/auth_cfg_wrapper.c b/src/libstrongswan/credentials/sets/auth_cfg_wrapper.c
index 8393d5b18..1cd4b9d03 100644
--- a/src/libstrongswan/credentials/sets/auth_cfg_wrapper.c
+++ b/src/libstrongswan/credentials/sets/auth_cfg_wrapper.c
@@ -112,15 +112,15 @@ static bool fetch_cert(wrapper_enumerator_t *enumerator,
return TRUE;
}
-/**
- * enumerate function for wrapper_enumerator_t
- */
-static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
+METHOD(enumerator_t, enumerate, bool,
+ wrapper_enumerator_t *this, va_list args)
{
auth_rule_t rule;
- certificate_t *current;
+ certificate_t *current, **cert;
public_key_t *public;
+ VA_ARGS_VGET(args, cert);
+
while (this->inner->enumerate(this->inner, &rule, &current))
{
if (rule == AUTH_HELPER_IM_HASH_URL ||
@@ -164,10 +164,8 @@ static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
return FALSE;
}
-/**
- * destroy function for wrapper_enumerator_t
- */
-static void wrapper_enumerator_destroy(wrapper_enumerator_t *this)
+METHOD(enumerator_t, wrapper_enumerator_destroy, void,
+ wrapper_enumerator_t *this)
{
this->inner->destroy(this->inner);
free(this);
@@ -183,14 +181,18 @@ METHOD(credential_set_t, create_enumerator, enumerator_t*,
{
return NULL;
}
- enumerator = malloc_thing(wrapper_enumerator_t);
- enumerator->auth = this->auth;
- enumerator->cert = cert;
- enumerator->key = key;
- enumerator->id = id;
- enumerator->inner = this->auth->create_enumerator(this->auth);
- enumerator->public.enumerate = (void*)enumerate;
- enumerator->public.destroy = (void*)wrapper_enumerator_destroy;
+ INIT(enumerator,
+ .public = {
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate,
+ .destroy = _wrapper_enumerator_destroy,
+ },
+ .auth = this->auth,
+ .cert = cert,
+ .key = key,
+ .id = id,
+ .inner = this->auth->create_enumerator(this->auth),
+ );
return &enumerator->public;
}
diff --git a/src/libstrongswan/credentials/sets/callback_cred.c b/src/libstrongswan/credentials/sets/callback_cred.c
index bff33f029..0d72452da 100644
--- a/src/libstrongswan/credentials/sets/callback_cred.c
+++ b/src/libstrongswan/credentials/sets/callback_cred.c
@@ -60,9 +60,12 @@ typedef struct {
} shared_enumerator_t;
METHOD(enumerator_t, shared_enumerate, bool,
- shared_enumerator_t *this, shared_key_t **out,
- id_match_t *match_me, id_match_t *match_other)
+ shared_enumerator_t *this, va_list args)
{
+ shared_key_t **out;
+ id_match_t *match_me, *match_other;
+
+ VA_ARGS_VGET(args, out, match_me, match_other);
DESTROY_IF(this->current);
this->current = this->this->cb.shared(this->this->data, this->type,
this->me, this->other, match_me, match_other);
@@ -89,7 +92,8 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
INIT(enumerator,
.public = {
- .enumerate = (void*)_shared_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _shared_enumerate,
.destroy = _shared_destroy,
},
.this = this,
diff --git a/src/libstrongswan/credentials/sets/cert_cache.c b/src/libstrongswan/credentials/sets/cert_cache.c
index 24fdb194b..92d5efdc6 100644
--- a/src/libstrongswan/credentials/sets/cert_cache.c
+++ b/src/libstrongswan/credentials/sets/cert_cache.c
@@ -252,13 +252,14 @@ typedef struct {
int locked;
} cert_enumerator_t;
-/**
- * filter function for certs enumerator
- */
-static bool cert_enumerate(cert_enumerator_t *this, certificate_t **out)
+METHOD(enumerator_t, cert_enumerate, bool,
+ cert_enumerator_t *this, va_list args)
{
public_key_t *public;
relation_t *rel;
+ certificate_t **out;
+
+ VA_ARGS_VGET(args, out);
if (this->locked >= 0)
{
@@ -311,10 +312,8 @@ static bool cert_enumerate(cert_enumerator_t *this, certificate_t **out)
return FALSE;
}
-/**
- * clean up enumeration data
- */
-static void cert_enumerator_destroy(cert_enumerator_t *this)
+METHOD(enumerator_t, cert_enumerator_destroy, void,
+ cert_enumerator_t *this)
{
relation_t *rel;
@@ -336,16 +335,19 @@ METHOD(credential_set_t, create_enumerator, enumerator_t*,
{
return NULL;
}
- enumerator = malloc_thing(cert_enumerator_t);
- enumerator->public.enumerate = (void*)cert_enumerate;
- enumerator->public.destroy = (void*)cert_enumerator_destroy;
- enumerator->cert = cert;
- enumerator->key = key;
- enumerator->id = id;
- enumerator->relations = this->relations;
- enumerator->index = -1;
- enumerator->locked = -1;
-
+ INIT(enumerator,
+ .public = {
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _cert_enumerate,
+ .destroy = _cert_enumerator_destroy,
+ },
+ .cert = cert,
+ .key = key,
+ .id = id,
+ .relations = this->relations,
+ .index = -1,
+ .locked = -1,
+ );
return &enumerator->public;
}
diff --git a/src/libstrongswan/credentials/sets/mem_cred.c b/src/libstrongswan/credentials/sets/mem_cred.c
index 53e035f98..4d594e439 100644
--- a/src/libstrongswan/credentials/sets/mem_cred.c
+++ b/src/libstrongswan/credentials/sets/mem_cred.c
@@ -74,25 +74,27 @@ typedef struct {
identification_t *id;
} cert_data_t;
-/**
- * destroy cert_data
- */
-static void cert_data_destroy(cert_data_t *data)
+CALLBACK(cert_data_destroy, void,
+ cert_data_t *data)
{
data->lock->unlock(data->lock);
free(data);
}
-/**
- * filter function for certs enumerator
- */
-static bool certs_filter(cert_data_t *data, certificate_t **in, certificate_t **out)
+CALLBACK(certs_filter, bool,
+ cert_data_t *data, enumerator_t *orig, va_list args)
{
public_key_t *public;
- certificate_t *cert = *in;
+ certificate_t *cert, **out;
+
+ VA_ARGS_VGET(args, out);
- if (data->cert == CERT_ANY || data->cert == cert->get_type(cert))
+ while (orig->enumerate(orig, &cert))
{
+ if (data->cert != CERT_ANY && data->cert != cert->get_type(cert))
+ {
+ continue;
+ }
public = cert->get_public_key(cert);
if (public)
{
@@ -102,7 +104,7 @@ static bool certs_filter(cert_data_t *data, certificate_t **in, certificate_t **
data->id->get_encoding(data->id)))
{
public->destroy(public);
- *out = *in;
+ *out = cert;
return TRUE;
}
}
@@ -110,11 +112,11 @@ static bool certs_filter(cert_data_t *data, certificate_t **in, certificate_t **
}
else if (data->key != KEY_ANY)
{
- return FALSE;
+ continue;
}
- if (data->id == NULL || cert->has_subject(cert, data->id))
+ if (!data->id || cert->has_subject(cert, data->id))
{
- *out = *in;
+ *out = cert;
return TRUE;
}
}
@@ -143,12 +145,16 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
{
enumerator = this->untrusted->create_enumerator(this->untrusted);
}
- return enumerator_create_filter(enumerator, (void*)certs_filter, data,
- (void*)cert_data_destroy);
+ return enumerator_create_filter(enumerator, certs_filter, data,
+ cert_data_destroy);
}
-static bool certificate_equals(certificate_t *item, certificate_t *cert)
+CALLBACK(certificate_equals, bool,
+ certificate_t *item, va_list args)
{
+ certificate_t *cert;
+
+ VA_ARGS_VGET(args, cert);
return item->equals(item, cert);
}
@@ -161,9 +167,8 @@ static certificate_t *add_cert_internal(private_mem_cred_t *this, bool trusted,
{
certificate_t *cached;
this->lock->write_lock(this->lock);
- if (this->untrusted->find_first(this->untrusted,
- (linked_list_match_t)certificate_equals,
- (void**)&cached, cert) == SUCCESS)
+ if (this->untrusted->find_first(this->untrusted, certificate_equals,
+ (void**)&cached, cert))
{
cert->destroy(cert);
cert = cached->get_ref(cached);
@@ -199,9 +204,8 @@ METHOD(mem_cred_t, get_cert_ref, certificate_t*,
certificate_t *cached;
this->lock->read_lock(this->lock);
- if (this->untrusted->find_first(this->untrusted,
- (linked_list_match_t)certificate_equals,
- (void**)&cached, cert) == SUCCESS)
+ if (this->untrusted->find_first(this->untrusted, certificate_equals,
+ (void**)&cached, cert))
{
cert->destroy(cert);
cert = cached->get_ref(cached);
@@ -301,30 +305,30 @@ typedef struct {
identification_t *id;
} key_data_t;
-/**
- * Destroy key enumerator data
- */
-static void key_data_destroy(key_data_t *data)
+CALLBACK(key_data_destroy, void,
+ key_data_t *data)
{
data->lock->unlock(data->lock);
free(data);
}
-/**
- * filter function for private key enumerator
- */
-static bool key_filter(key_data_t *data, private_key_t **in, private_key_t **out)
+CALLBACK(key_filter, bool,
+ key_data_t *data, enumerator_t *orig, va_list args)
{
- private_key_t *key;
+ private_key_t *key, **out;
+
+ VA_ARGS_VGET(args, out);
- key = *in;
- if (data->type == KEY_ANY || data->type == key->get_type(key))
+ while (orig->enumerate(orig, &key))
{
- if (data->id == NULL ||
- key->has_fingerprint(key, data->id->get_encoding(data->id)))
+ if (data->type == KEY_ANY || data->type == key->get_type(key))
{
- *out = key;
- return TRUE;
+ if (data->id == NULL ||
+ key->has_fingerprint(key, data->id->get_encoding(data->id)))
+ {
+ *out = key;
+ return TRUE;
+ }
}
}
return FALSE;
@@ -342,7 +346,7 @@ METHOD(credential_set_t, create_private_enumerator, enumerator_t*,
);
this->lock->read_lock(this->lock);
return enumerator_create_filter(this->keys->create_enumerator(this->keys),
- (void*)key_filter, data, (void*)key_data_destroy);
+ key_filter, data, key_data_destroy);
}
METHOD(mem_cred_t, add_key, void,
@@ -468,10 +472,8 @@ typedef struct {
shared_key_type_t type;
} shared_data_t;
-/**
- * free shared key enumerator data and unlock list
- */
-static void shared_data_destroy(shared_data_t *data)
+CALLBACK(shared_data_destroy, void,
+ shared_data_t *data)
{
data->lock->unlock(data->lock);
free(data);
@@ -499,44 +501,47 @@ static id_match_t has_owner(shared_entry_t *entry, identification_t *owner)
return best;
}
-/**
- * enumerator filter function for shared entries
- */
-static bool shared_filter(shared_data_t *data,
- shared_entry_t **in, shared_key_t **out,
- void **unused1, id_match_t *me,
- void **unused2, id_match_t *other)
+CALLBACK(shared_filter, bool,
+ shared_data_t *data, enumerator_t *orig, va_list args)
{
id_match_t my_match = ID_MATCH_NONE, other_match = ID_MATCH_NONE;
- shared_entry_t *entry = *in;
+ shared_entry_t *entry;
+ shared_key_t **out;
+ id_match_t *me, *other;
- if (data->type != SHARED_ANY &&
- entry->shared->get_type(entry->shared) != data->type)
- {
- return FALSE;
- }
- if (data->me)
- {
- my_match = has_owner(entry, data->me);
- }
- if (data->other)
- {
- other_match = has_owner(entry, data->other);
- }
- if ((data->me || data->other) && (!my_match && !other_match))
- {
- return FALSE;
- }
- *out = entry->shared;
- if (me)
- {
- *me = my_match;
- }
- if (other)
+ VA_ARGS_VGET(args, out, me, other);
+
+ while (orig->enumerate(orig, &entry))
{
- *other = other_match;
+ if (data->type != SHARED_ANY &&
+ entry->shared->get_type(entry->shared) != data->type)
+ {
+ continue;
+ }
+ if (data->me)
+ {
+ my_match = has_owner(entry, data->me);
+ }
+ if (data->other)
+ {
+ other_match = has_owner(entry, data->other);
+ }
+ if ((data->me || data->other) && (!my_match && !other_match))
+ {
+ continue;
+ }
+ *out = entry->shared;
+ if (me)
+ {
+ *me = my_match;
+ }
+ if (other)
+ {
+ *other = other_match;
+ }
+ return TRUE;
}
- return TRUE;
+ return FALSE;
}
METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
@@ -554,7 +559,7 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
data->lock->read_lock(data->lock);
return enumerator_create_filter(
this->shared->create_enumerator(this->shared),
- (void*)shared_filter, data, (void*)shared_data_destroy);
+ shared_filter, data, shared_data_destroy);
}
METHOD(mem_cred_t, add_shared_unique, void,
@@ -648,23 +653,27 @@ METHOD(mem_cred_t, remove_shared_unique, void,
this->lock->unlock(this->lock);
}
-/**
- * Filter unique ids of shared keys (ingore secrets without unique id)
- */
-static bool unique_filter(void *unused,
- shared_entry_t **in, char **id)
+CALLBACK(unique_filter, bool,
+ void *unused, enumerator_t *orig, va_list args)
{
- shared_entry_t *entry = *in;
+ shared_entry_t *entry;
+ char **id;
- if (!entry->id)
- {
- return FALSE;
- }
- if (id)
+ VA_ARGS_VGET(args, id);
+
+ while (orig->enumerate(orig, &entry))
{
- *id = entry->id;
+ if (!entry->id)
+ {
+ continue;
+ }
+ if (id)
+ {
+ *id = entry->id;
+ }
+ return TRUE;
}
- return TRUE;
+ return FALSE;
}
METHOD(mem_cred_t, create_unique_shared_enumerator, enumerator_t*,
@@ -673,7 +682,7 @@ METHOD(mem_cred_t, create_unique_shared_enumerator, enumerator_t*,
this->lock->read_lock(this->lock);
return enumerator_create_filter(
this->shared->create_enumerator(this->shared),
- (void*)unique_filter, this->lock,
+ unique_filter, this->lock,
(void*)this->lock->unlock);
}
@@ -721,30 +730,35 @@ typedef struct {
rwlock_t *lock;
} cdp_data_t;
-/**
- * Clean up CDP enumerator data
- */
-static void cdp_data_destroy(cdp_data_t *data)
+CALLBACK(cdp_data_destroy, void,
+ cdp_data_t *data)
{
data->lock->unlock(data->lock);
free(data);
}
-/**
- * CDP enumerator filter
- */
-static bool cdp_filter(cdp_data_t *data, cdp_t **cdp, char **uri)
+CALLBACK(cdp_filter, bool,
+ cdp_data_t *data, enumerator_t *orig, va_list args)
{
- if (data->type != CERT_ANY && data->type != (*cdp)->type)
- {
- return FALSE;
- }
- if (data->id && !(*cdp)->id->matches((*cdp)->id, data->id))
+ cdp_t *cdp;
+ char **uri;
+
+ VA_ARGS_VGET(args, uri);
+
+ while (orig->enumerate(orig, &cdp))
{
- return FALSE;
+ if (data->type != CERT_ANY && data->type != cdp->type)
+ {
+ continue;
+ }
+ if (data->id && !cdp->id->matches(cdp->id, data->id))
+ {
+ continue;
+ }
+ *uri = cdp->uri;
+ return TRUE;
}
- *uri = (*cdp)->uri;
- return TRUE;
+ return FALSE;
}
METHOD(credential_set_t, create_cdp_enumerator, enumerator_t*,
@@ -759,7 +773,7 @@ METHOD(credential_set_t, create_cdp_enumerator, enumerator_t*,
);
this->lock->read_lock(this->lock);
return enumerator_create_filter(this->cdps->create_enumerator(this->cdps),
- (void*)cdp_filter, data, (void*)cdp_data_destroy);
+ cdp_filter, data, cdp_data_destroy);
}
diff --git a/src/libstrongswan/credentials/sets/mem_cred.h b/src/libstrongswan/credentials/sets/mem_cred.h
index 135515260..f55c3ccdf 100644
--- a/src/libstrongswan/credentials/sets/mem_cred.h
+++ b/src/libstrongswan/credentials/sets/mem_cred.h
@@ -62,7 +62,7 @@ struct mem_cred_t {
/**
* Get an existing reference to the same certificate.
*
- * Searches for the same certficate in the set, and returns a reference
+ * Searches for the same certificate in the set, and returns a reference
* to it, destroying the passed certificate. If the passed certificate
* is not found, it is just returned.
*
diff --git a/src/libstrongswan/credentials/sets/ocsp_response_wrapper.c b/src/libstrongswan/credentials/sets/ocsp_response_wrapper.c
index 151d69216..12d3f8156 100644
--- a/src/libstrongswan/credentials/sets/ocsp_response_wrapper.c
+++ b/src/libstrongswan/credentials/sets/ocsp_response_wrapper.c
@@ -49,14 +49,15 @@ typedef struct {
identification_t *id;
} wrapper_enumerator_t;
-/**
- * enumerate function wrapper_enumerator_t
- */
-static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
+METHOD(enumerator_t, enumerate, bool,
+ wrapper_enumerator_t *this, va_list args)
{
- certificate_t *current;
+ certificate_t *current, **cert;
public_key_t *public;
+
+ VA_ARGS_VGET(args, cert);
+
while (this->inner->enumerate(this->inner, &current))
{
if (this->cert != CERT_ANY && this->cert != current->get_type(current))
@@ -85,10 +86,8 @@ static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
return FALSE;
}
-/**
- * destroy function for wrapper_enumerator_t
- */
-static void enumerator_destroy(wrapper_enumerator_t *this)
+METHOD(enumerator_t, enumerator_destroy, void,
+ wrapper_enumerator_t *this)
{
this->inner->destroy(this->inner);
free(this);
@@ -105,13 +104,17 @@ METHOD(credential_set_t, create_enumerator, enumerator_t*,
return NULL;
}
- enumerator = malloc_thing(wrapper_enumerator_t);
- enumerator->cert = cert;
- enumerator->key = key;
- enumerator->id = id;
- enumerator->inner = this->response->create_cert_enumerator(this->response);
- enumerator->public.enumerate = (void*)enumerate;
- enumerator->public.destroy = (void*)enumerator_destroy;
+ INIT(enumerator,
+ .public = {
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate,
+ .destroy = _enumerator_destroy,
+ },
+ .cert = cert,
+ .key = key,
+ .id = id,
+ .inner = this->response->create_cert_enumerator(this->response),
+ );
return &enumerator->public;
}
diff --git a/src/libstrongswan/crypto/crypto_factory.c b/src/libstrongswan/crypto/crypto_factory.c
index bab59a06f..096bcbc9c 100644
--- a/src/libstrongswan/crypto/crypto_factory.c
+++ b/src/libstrongswan/crypto/crypto_factory.c
@@ -811,51 +811,66 @@ METHOD(crypto_factory_t, remove_dh, void,
this->lock->unlock(this->lock);
}
-/**
- * match algorithms of an entry?
- */
-static bool entry_match(entry_t *a, entry_t *b)
+CALLBACK(entry_match, bool,
+ entry_t *a, va_list args)
{
+ entry_t *b;
+
+ VA_ARGS_VGET(args, b);
return a->algo == b->algo;
}
-/**
- * check for uniqueness of an entry
- */
-static bool unique_check(linked_list_t *list, entry_t **in, entry_t **out)
+CALLBACK(unique_check, bool,
+ linked_list_t *list, enumerator_t *orig, va_list args)
{
- if (list->find_first(list, (void*)entry_match, NULL, *in) == SUCCESS)
+ entry_t *entry, **out;
+
+ VA_ARGS_VGET(args, out);
+
+ while (orig->enumerate(orig, &entry))
{
- return FALSE;
+ if (list->find_first(list, entry_match, NULL, entry))
+ {
+ continue;
+ }
+ *out = entry;
+ list->insert_last(list, entry);
+ return TRUE;
}
- *out = *in;
- list->insert_last(list, *in);
- return TRUE;
+ return FALSE;
}
/**
* create an enumerator over entry->algo in list with locking and unique check
*/
static enumerator_t *create_enumerator(private_crypto_factory_t *this,
- linked_list_t *list, void *filter)
+ linked_list_t *list,
+ bool (*filter)(void*,enumerator_t*,va_list))
{
this->lock->read_lock(this->lock);
return enumerator_create_filter(
enumerator_create_filter(
- list->create_enumerator(list), (void*)unique_check,
+ list->create_enumerator(list), unique_check,
linked_list_create(), (void*)list->destroy),
filter, this->lock, (void*)this->lock->unlock);
}
-/**
- * Filter function to enumerate algorithm, not entry
- */
-static bool crypter_filter(void *n, entry_t **entry, encryption_algorithm_t *algo,
- void *i2, const char **plugin_name)
+CALLBACK(crypter_filter, bool,
+ void *n, enumerator_t *orig, va_list args)
{
- *algo = (*entry)->algo;
- *plugin_name = (*entry)->plugin_name;
- return TRUE;
+ entry_t *entry;
+ encryption_algorithm_t *algo;
+ const char **plugin_name;
+
+ VA_ARGS_VGET(args, algo, plugin_name);
+
+ if (orig->enumerate(orig, &entry))
+ {
+ *algo = entry->algo;
+ *plugin_name = entry->plugin_name;
+ return TRUE;
+ }
+ return FALSE;
}
METHOD(crypto_factory_t, create_crypter_enumerator, enumerator_t*,
@@ -870,15 +885,22 @@ METHOD(crypto_factory_t, create_aead_enumerator, enumerator_t*,
return create_enumerator(this, this->aeads, crypter_filter);
}
-/**
- * Filter function to enumerate algorithm, not entry
- */
-static bool signer_filter(void *n, entry_t **entry, integrity_algorithm_t *algo,
- void *i2, const char **plugin_name)
+CALLBACK(signer_filter, bool,
+ void *n, enumerator_t *orig, va_list args)
{
- *algo = (*entry)->algo;
- *plugin_name = (*entry)->plugin_name;
- return TRUE;
+ entry_t *entry;
+ integrity_algorithm_t *algo;
+ const char **plugin_name;
+
+ VA_ARGS_VGET(args, algo, plugin_name);
+
+ if (orig->enumerate(orig, &entry))
+ {
+ *algo = entry->algo;
+ *plugin_name = entry->plugin_name;
+ return TRUE;
+ }
+ return FALSE;
}
METHOD(crypto_factory_t, create_signer_enumerator, enumerator_t*,
@@ -887,15 +909,22 @@ METHOD(crypto_factory_t, create_signer_enumerator, enumerator_t*,
return create_enumerator(this, this->signers, signer_filter);
}
-/**
- * Filter function to enumerate algorithm, not entry
- */
-static bool hasher_filter(void *n, entry_t **entry, hash_algorithm_t *algo,
- void *i2, const char **plugin_name)
+CALLBACK(hasher_filter, bool,
+ void *n, enumerator_t *orig, va_list args)
{
- *algo = (*entry)->algo;
- *plugin_name = (*entry)->plugin_name;
- return TRUE;
+ entry_t *entry;
+ hash_algorithm_t *algo;
+ const char **plugin_name;
+
+ VA_ARGS_VGET(args, algo, plugin_name);
+
+ if (orig->enumerate(orig, &entry))
+ {
+ *algo = entry->algo;
+ *plugin_name = entry->plugin_name;
+ return TRUE;
+ }
+ return FALSE;
}
METHOD(crypto_factory_t, create_hasher_enumerator, enumerator_t*,
@@ -904,15 +933,22 @@ METHOD(crypto_factory_t, create_hasher_enumerator, enumerator_t*,
return create_enumerator(this, this->hashers, hasher_filter);
}
-/**
- * Filter function to enumerate algorithm, not entry
- */
-static bool prf_filter(void *n, entry_t **entry, pseudo_random_function_t *algo,
- void *i2, const char **plugin_name)
+CALLBACK(prf_filter, bool,
+ void *n, enumerator_t *orig, va_list args)
{
- *algo = (*entry)->algo;
- *plugin_name = (*entry)->plugin_name;
- return TRUE;
+ entry_t *entry;
+ pseudo_random_function_t *algo;
+ const char **plugin_name;
+
+ VA_ARGS_VGET(args, algo, plugin_name);
+
+ if (orig->enumerate(orig, &entry))
+ {
+ *algo = entry->algo;
+ *plugin_name = entry->plugin_name;
+ return TRUE;
+ }
+ return FALSE;
}
METHOD(crypto_factory_t, create_prf_enumerator, enumerator_t*,
@@ -921,15 +957,22 @@ METHOD(crypto_factory_t, create_prf_enumerator, enumerator_t*,
return create_enumerator(this, this->prfs, prf_filter);
}
-/**
- * Filter function to enumerate algorithm, not entry
- */
-static bool xof_filter(void *n, entry_t **entry, ext_out_function_t *algo,
- void *i2, const char **plugin_name)
+CALLBACK(xof_filter, bool,
+ void *n, enumerator_t *orig, va_list args)
{
- *algo = (*entry)->algo;
- *plugin_name = (*entry)->plugin_name;
- return TRUE;
+ entry_t *entry;
+ ext_out_function_t *algo;
+ const char **plugin_name;
+
+ VA_ARGS_VGET(args, algo, plugin_name);
+
+ if (orig->enumerate(orig, &entry))
+ {
+ *algo = entry->algo;
+ *plugin_name = entry->plugin_name;
+ return TRUE;
+ }
+ return FALSE;
}
METHOD(crypto_factory_t, create_xof_enumerator, enumerator_t*,
@@ -938,15 +981,22 @@ METHOD(crypto_factory_t, create_xof_enumerator, enumerator_t*,
return create_enumerator(this, this->xofs, xof_filter);
}
-/**
- * Filter function to enumerate group, not entry
- */
-static bool dh_filter(void *n, entry_t **entry, diffie_hellman_group_t *group,
- void *i2, const char **plugin_name)
+CALLBACK(dh_filter, bool,
+ void *n, enumerator_t *orig, va_list args)
{
- *group = (*entry)->algo;
- *plugin_name = (*entry)->plugin_name;
- return TRUE;
+ entry_t *entry;
+ diffie_hellman_group_t *algo;
+ const char **plugin_name;
+
+ VA_ARGS_VGET(args, algo, plugin_name);
+
+ if (orig->enumerate(orig, &entry))
+ {
+ *algo = entry->algo;
+ *plugin_name = entry->plugin_name;
+ return TRUE;
+ }
+ return FALSE;
}
METHOD(crypto_factory_t, create_dh_enumerator, enumerator_t*,
@@ -955,15 +1005,22 @@ METHOD(crypto_factory_t, create_dh_enumerator, enumerator_t*,
return create_enumerator(this, this->dhs, dh_filter);
}
-/**
- * Filter function to enumerate strength, not entry
- */
-static bool rng_filter(void *n, entry_t **entry, rng_quality_t *quality,
- void *i2, const char **plugin_name)
+CALLBACK(rng_filter, bool,
+ void *n, enumerator_t *orig, va_list args)
{
- *quality = (*entry)->algo;
- *plugin_name = (*entry)->plugin_name;
- return TRUE;
+ entry_t *entry;
+ rng_quality_t *algo;
+ const char **plugin_name;
+
+ VA_ARGS_VGET(args, algo, plugin_name);
+
+ if (orig->enumerate(orig, &entry))
+ {
+ *algo = entry->algo;
+ *plugin_name = entry->plugin_name;
+ return TRUE;
+ }
+ return FALSE;
}
METHOD(crypto_factory_t, create_rng_enumerator, enumerator_t*,
@@ -972,13 +1029,20 @@ METHOD(crypto_factory_t, create_rng_enumerator, enumerator_t*,
return create_enumerator(this, this->rngs, rng_filter);
}
-/**
- * Filter function to enumerate plugin name, not entry
- */
-static bool nonce_gen_filter(void *n, entry_t **entry, const char **plugin_name)
+CALLBACK(nonce_gen_filter, bool,
+ void *n, enumerator_t *orig, va_list args)
{
- *plugin_name = (*entry)->plugin_name;
- return TRUE;
+ entry_t *entry;
+ const char **plugin_name;
+
+ VA_ARGS_VGET(args, plugin_name);
+
+ if (orig->enumerate(orig, &entry))
+ {
+ *plugin_name = entry->plugin_name;
+ return TRUE;
+ }
+ return FALSE;
}
METHOD(crypto_factory_t, create_nonce_gen_enumerator, enumerator_t*,
@@ -1026,9 +1090,14 @@ typedef struct {
} verify_enumerator_t;
METHOD(enumerator_t, verify_enumerate, bool,
- verify_enumerator_t *this, u_int *alg, const char **plugin, bool *valid)
+ verify_enumerator_t *this, va_list args)
{
+ const char **plugin;
entry_t *entry;
+ u_int *alg;
+ bool *valid;
+
+ VA_ARGS_VGET(args, alg, plugin, valid);
if (!this->inner->enumerate(this->inner, &entry))
{
@@ -1123,7 +1192,8 @@ METHOD(crypto_factory_t, create_verify_enumerator, enumerator_t*,
}
INIT(enumerator,
.public = {
- .enumerate = (void*)_verify_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _verify_enumerate,
.destroy = _verify_destroy,
},
.inner = inner,
diff --git a/src/libstrongswan/crypto/hashers/hash_algorithm_set.c b/src/libstrongswan/crypto/hashers/hash_algorithm_set.c
index 93b67cb13..4087fe1d9 100644
--- a/src/libstrongswan/crypto/hashers/hash_algorithm_set.c
+++ b/src/libstrongswan/crypto/hashers/hash_algorithm_set.c
@@ -71,17 +71,26 @@ METHOD(hash_algorithm_set_t, count, int,
return array_count(this->algorithms);
}
-static bool hash_filter(void *data, void **in, hash_algorithm_t *out)
+CALLBACK(hash_filter, bool,
+ void *data, enumerator_t *orig, va_list args)
{
- *out = **(hash_algorithm_t**)in;
- return TRUE;
+ hash_algorithm_t *algo, *out;
+
+ VA_ARGS_VGET(args, out);
+
+ if (orig->enumerate(orig, &algo))
+ {
+ *out = *algo;
+ return TRUE;
+ }
+ return FALSE;
}
METHOD(hash_algorithm_set_t, create_enumerator, enumerator_t*,
private_hash_algorithm_set_t *this)
{
return enumerator_create_filter(array_create_enumerator(this->algorithms),
- (void*)hash_filter, NULL, NULL);
+ hash_filter, NULL, NULL);
}
METHOD(hash_algorithm_set_t, destroy, void,
diff --git a/src/libstrongswan/library.c b/src/libstrongswan/library.c
index 4f79dcc5b..7944b9356 100644
--- a/src/libstrongswan/library.c
+++ b/src/libstrongswan/library.c
@@ -94,6 +94,13 @@ void library_add_namespace(char *ns)
}
/**
+ * Register plugins if built statically
+ */
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+#include "plugin_constructors.c"
+#endif
+
+/**
* library instance
*/
library_t *lib = NULL;
@@ -241,6 +248,8 @@ static bool equals(char *a, char *b)
*/
#define MEMWIPE_WIPE_WORDS 16
+#ifndef NO_CHECK_MEMWIPE
+
/**
* Write magic to memory, and try to clear it with memwipe()
*/
@@ -281,6 +290,8 @@ static bool check_memwipe()
return TRUE;
}
+#endif
+
/*
* see header file
*/
@@ -387,10 +398,12 @@ bool library_init(char *settings, const char *namespace)
this->public.streams = stream_manager_create();
this->public.plugins = plugin_loader_create();
+#ifndef NO_CHECK_MEMWIPE
if (!check_memwipe())
{
return FALSE;
}
+#endif
if (lib->settings->get_bool(lib->settings,
"%s.integrity_test", FALSE, lib->ns))
diff --git a/src/libstrongswan/math/libnttfft/Makefile.in b/src/libstrongswan/math/libnttfft/Makefile.in
index ff41f9be4..93bd93508 100644
--- a/src/libstrongswan/math/libnttfft/Makefile.in
+++ b/src/libstrongswan/math/libnttfft/Makefile.in
@@ -349,6 +349,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -371,6 +372,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/math/libnttfft/tests/Makefile.in b/src/libstrongswan/math/libnttfft/tests/Makefile.in
index 4f854494b..80ecd3ea7 100644
--- a/src/libstrongswan/math/libnttfft/tests/Makefile.in
+++ b/src/libstrongswan/math/libnttfft/tests/Makefile.in
@@ -353,6 +353,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -375,6 +376,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/networking/tun_device.c b/src/libstrongswan/networking/tun_device.c
index de925553f..86951f1e7 100644
--- a/src/libstrongswan/networking/tun_device.c
+++ b/src/libstrongswan/networking/tun_device.c
@@ -21,7 +21,16 @@
#include <utils/debug.h>
#include <threading/thread.h>
-#if !defined(__APPLE__) && !defined(__linux__) && !defined(HAVE_NET_IF_TUN_H)
+#if defined(__APPLE__)
+#include "TargetConditionals.h"
+#if !TARGET_OS_OSX
+#define TUN_DEVICE_NOT_SUPPORTED
+#endif
+#elif !defined(__linux__) && !defined(HAVE_NET_IF_TUN_H)
+#define TUN_DEVICE_NOT_SUPPORTED
+#endif
+
+#ifdef TUN_DEVICE_NOT_SUPPORTED
tun_device_t *tun_device_create(const char *name_tmpl)
{
@@ -481,10 +490,25 @@ static bool init_tun(private_tun_device_t *this, const char *name_tmpl)
strncpy(this->if_name, ifr.ifr_name, IFNAMSIZ);
return TRUE;
-#else /* !IFF_TUN */
+#elif defined(__FreeBSD__)
+
+ if (name_tmpl)
+ {
+ DBG1(DBG_LIB, "arbitrary naming of TUN devices is not supported");
+ }
+
+ this->tunfd = open("/dev/tun", O_RDWR);
+ if (this->tunfd < 0)
+ {
+ DBG1(DBG_LIB, "failed to open /dev/tun: %s", strerror(errno));
+ return FALSE;
+ }
+ fdevname_r(this->tunfd, this->if_name, IFNAMSIZ);
+ return TRUE;
+
+#else /* !__FreeBSD__ */
- /* this works on FreeBSD and might also work on Linux with older TUN
- * driver versions (no IFF_TUN) */
+ /* this might work on Linux with older TUN driver versions (no IFF_TUN) */
char devname[IFNAMSIZ];
/* the same process is allowed to open a device again, but that's not what
* we want (unless we previously closed a device, which we don't know at
diff --git a/src/libstrongswan/plugins/acert/Makefile.in b/src/libstrongswan/plugins/acert/Makefile.in
index ee69a8914..1dcc0489e 100644
--- a/src/libstrongswan/plugins/acert/Makefile.in
+++ b/src/libstrongswan/plugins/acert/Makefile.in
@@ -356,6 +356,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -378,6 +379,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/aes/Makefile.in b/src/libstrongswan/plugins/aes/Makefile.in
index 0a8046b67..2b16ae7d2 100644
--- a/src/libstrongswan/plugins/aes/Makefile.in
+++ b/src/libstrongswan/plugins/aes/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/aesni/Makefile.in b/src/libstrongswan/plugins/aesni/Makefile.in
index ceb86762e..d32e7f55c 100644
--- a/src/libstrongswan/plugins/aesni/Makefile.in
+++ b/src/libstrongswan/plugins/aesni/Makefile.in
@@ -358,6 +358,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -380,6 +381,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/af_alg/Makefile.in b/src/libstrongswan/plugins/af_alg/Makefile.in
index bad31cace..e93140279 100644
--- a/src/libstrongswan/plugins/af_alg/Makefile.in
+++ b/src/libstrongswan/plugins/af_alg/Makefile.in
@@ -359,6 +359,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -381,6 +382,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_ops.c b/src/libstrongswan/plugins/af_alg/af_alg_ops.c
index 7e129300f..2fa68723d 100644
--- a/src/libstrongswan/plugins/af_alg/af_alg_ops.c
+++ b/src/libstrongswan/plugins/af_alg/af_alg_ops.c
@@ -107,7 +107,7 @@ METHOD(af_alg_ops_t, hash, bool,
return TRUE;
}
-METHOD(af_alg_ops_t, crypt, bool,
+METHOD(af_alg_ops_t, crypt_, bool,
private_af_alg_ops_t *this, uint32_t type, chunk_t iv, chunk_t data,
char *out)
{
@@ -224,7 +224,7 @@ af_alg_ops_t *af_alg_ops_create(char *type, char *alg)
.public = {
.hash = _hash,
.reset = _reset,
- .crypt = _crypt,
+ .crypt = _crypt_,
.set_key = _set_key,
.destroy = _destroy,
},
diff --git a/src/libstrongswan/plugins/agent/Makefile.in b/src/libstrongswan/plugins/agent/Makefile.in
index cd9036b68..a4e7e2931 100644
--- a/src/libstrongswan/plugins/agent/Makefile.in
+++ b/src/libstrongswan/plugins/agent/Makefile.in
@@ -357,6 +357,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -379,6 +380,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/bliss/Makefile.in b/src/libstrongswan/plugins/bliss/Makefile.in
index 918a018f9..a6caf7bdf 100644
--- a/src/libstrongswan/plugins/bliss/Makefile.in
+++ b/src/libstrongswan/plugins/bliss/Makefile.in
@@ -380,6 +380,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -402,6 +403,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/bliss/tests/Makefile.in b/src/libstrongswan/plugins/bliss/tests/Makefile.in
index 1964f199f..5dbaf9b9b 100644
--- a/src/libstrongswan/plugins/bliss/tests/Makefile.in
+++ b/src/libstrongswan/plugins/bliss/tests/Makefile.in
@@ -359,6 +359,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -381,6 +382,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/blowfish/Makefile.in b/src/libstrongswan/plugins/blowfish/Makefile.in
index c2bc5acd9..0876475d0 100644
--- a/src/libstrongswan/plugins/blowfish/Makefile.in
+++ b/src/libstrongswan/plugins/blowfish/Makefile.in
@@ -358,6 +358,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -380,6 +381,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/ccm/Makefile.in b/src/libstrongswan/plugins/ccm/Makefile.in
index f0065d0b6..5f768ec8c 100644
--- a/src/libstrongswan/plugins/ccm/Makefile.in
+++ b/src/libstrongswan/plugins/ccm/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/chapoly/Makefile.in b/src/libstrongswan/plugins/chapoly/Makefile.in
index 3e1d634c2..12ad6f1b8 100644
--- a/src/libstrongswan/plugins/chapoly/Makefile.in
+++ b/src/libstrongswan/plugins/chapoly/Makefile.in
@@ -370,6 +370,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -392,6 +393,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/cmac/Makefile.in b/src/libstrongswan/plugins/cmac/Makefile.in
index 77d68bd5d..c6bb24a91 100644
--- a/src/libstrongswan/plugins/cmac/Makefile.in
+++ b/src/libstrongswan/plugins/cmac/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/constraints/Makefile.in b/src/libstrongswan/plugins/constraints/Makefile.in
index edd519f12..aa2fd790f 100644
--- a/src/libstrongswan/plugins/constraints/Makefile.in
+++ b/src/libstrongswan/plugins/constraints/Makefile.in
@@ -358,6 +358,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -380,6 +381,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/ctr/Makefile.in b/src/libstrongswan/plugins/ctr/Makefile.in
index a9d0b2e13..d112676e7 100644
--- a/src/libstrongswan/plugins/ctr/Makefile.in
+++ b/src/libstrongswan/plugins/ctr/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/curl/Makefile.in b/src/libstrongswan/plugins/curl/Makefile.in
index 996d25885..2aedb2f75 100644
--- a/src/libstrongswan/plugins/curl/Makefile.in
+++ b/src/libstrongswan/plugins/curl/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/curve25519/Makefile.in b/src/libstrongswan/plugins/curve25519/Makefile.in
index 1fa2b171b..616f3d83b 100644
--- a/src/libstrongswan/plugins/curve25519/Makefile.in
+++ b/src/libstrongswan/plugins/curve25519/Makefile.in
@@ -362,6 +362,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -384,6 +385,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/des/Makefile.in b/src/libstrongswan/plugins/des/Makefile.in
index b6cedd8e8..c3f3775d2 100644
--- a/src/libstrongswan/plugins/des/Makefile.in
+++ b/src/libstrongswan/plugins/des/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/dnskey/Makefile.in b/src/libstrongswan/plugins/dnskey/Makefile.in
index 347c69739..26c69e239 100644
--- a/src/libstrongswan/plugins/dnskey/Makefile.in
+++ b/src/libstrongswan/plugins/dnskey/Makefile.in
@@ -358,6 +358,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -380,6 +381,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/files/Makefile.in b/src/libstrongswan/plugins/files/Makefile.in
index 10cbc6e76..d8c7daec4 100644
--- a/src/libstrongswan/plugins/files/Makefile.in
+++ b/src/libstrongswan/plugins/files/Makefile.in
@@ -356,6 +356,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -378,6 +379,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/fips_prf/Makefile.in b/src/libstrongswan/plugins/fips_prf/Makefile.in
index 8b5e162ac..45934d79a 100644
--- a/src/libstrongswan/plugins/fips_prf/Makefile.in
+++ b/src/libstrongswan/plugins/fips_prf/Makefile.in
@@ -357,6 +357,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -379,6 +380,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/gcm/Makefile.in b/src/libstrongswan/plugins/gcm/Makefile.in
index 0f3878fb5..5d6c1a4e9 100644
--- a/src/libstrongswan/plugins/gcm/Makefile.in
+++ b/src/libstrongswan/plugins/gcm/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/gcrypt/Makefile.in b/src/libstrongswan/plugins/gcrypt/Makefile.in
index ef246f99a..26930dced 100644
--- a/src/libstrongswan/plugins/gcrypt/Makefile.in
+++ b/src/libstrongswan/plugins/gcrypt/Makefile.in
@@ -359,6 +359,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -381,6 +382,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/gmp/Makefile.in b/src/libstrongswan/plugins/gmp/Makefile.in
index de8f8fe7a..2fcdce774 100644
--- a/src/libstrongswan/plugins/gmp/Makefile.in
+++ b/src/libstrongswan/plugins/gmp/Makefile.in
@@ -356,6 +356,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -378,6 +379,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c b/src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c
index 2b2c7f249..32a72ac96 100644
--- a/src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c
+++ b/src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c
@@ -475,7 +475,7 @@ gmp_rsa_public_key_t *gmp_rsa_public_key_load(key_type_t type, va_list args)
}
break;
}
- if (!e.ptr || !n.ptr)
+ if (!e.len || !n.len || (n.ptr[n.len-1] & 0x01) == 0)
{
return NULL;
}
@@ -506,5 +506,10 @@ gmp_rsa_public_key_t *gmp_rsa_public_key_load(key_type_t type, va_list args)
this->k = (mpz_sizeinbase(this->n, 2) + 7) / BITS_PER_BYTE;
+ if (!mpz_sgn(this->e))
+ {
+ destroy(this);
+ return NULL;
+ }
return &this->public;
}
diff --git a/src/libstrongswan/plugins/hmac/Makefile.in b/src/libstrongswan/plugins/hmac/Makefile.in
index 3a87fcc02..aa640156a 100644
--- a/src/libstrongswan/plugins/hmac/Makefile.in
+++ b/src/libstrongswan/plugins/hmac/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/keychain/Makefile.in b/src/libstrongswan/plugins/keychain/Makefile.in
index d113d9ee2..c9e4e40e0 100644
--- a/src/libstrongswan/plugins/keychain/Makefile.in
+++ b/src/libstrongswan/plugins/keychain/Makefile.in
@@ -358,6 +358,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -380,6 +381,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/ldap/Makefile.in b/src/libstrongswan/plugins/ldap/Makefile.in
index 2005aafb9..1f4d44706 100644
--- a/src/libstrongswan/plugins/ldap/Makefile.in
+++ b/src/libstrongswan/plugins/ldap/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/md4/Makefile.in b/src/libstrongswan/plugins/md4/Makefile.in
index dad532715..eb9426ccc 100644
--- a/src/libstrongswan/plugins/md4/Makefile.in
+++ b/src/libstrongswan/plugins/md4/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/md5/Makefile.in b/src/libstrongswan/plugins/md5/Makefile.in
index 5f1ced2f3..eaafd9fe5 100644
--- a/src/libstrongswan/plugins/md5/Makefile.in
+++ b/src/libstrongswan/plugins/md5/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/mgf1/Makefile.in b/src/libstrongswan/plugins/mgf1/Makefile.in
index 42904a763..991c5421e 100644
--- a/src/libstrongswan/plugins/mgf1/Makefile.in
+++ b/src/libstrongswan/plugins/mgf1/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/mysql/Makefile.in b/src/libstrongswan/plugins/mysql/Makefile.in
index b61755716..d549f2e71 100644
--- a/src/libstrongswan/plugins/mysql/Makefile.in
+++ b/src/libstrongswan/plugins/mysql/Makefile.in
@@ -357,6 +357,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -379,6 +380,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/mysql/mysql_database.c b/src/libstrongswan/plugins/mysql/mysql_database.c
index 871cc59a0..211eba704 100644
--- a/src/libstrongswan/plugins/mysql/mysql_database.c
+++ b/src/libstrongswan/plugins/mysql/mysql_database.c
@@ -403,10 +403,8 @@ typedef struct {
unsigned long *length;
} mysql_enumerator_t;
-/**
- * create a mysql enumerator
- */
-static void mysql_enumerator_destroy(mysql_enumerator_t *this)
+METHOD(enumerator_t, mysql_enumerator_destroy, void,
+ mysql_enumerator_t *this)
{
int columns, i;
@@ -434,13 +432,10 @@ static void mysql_enumerator_destroy(mysql_enumerator_t *this)
free(this);
}
-/**
- * Implementation of database.query().enumerate
- */
-static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
+METHOD(enumerator_t, mysql_enumerator_enumerate, bool,
+ mysql_enumerator_t *this, va_list args)
{
int i, columns;
- va_list args;
columns = mysql_stmt_field_count(this->stmt);
@@ -477,7 +472,6 @@ static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
return FALSE;
}
- va_start(args, this);
for (i = 0; i < columns; i++)
{
switch (this->bind[i].buffer_type)
@@ -526,7 +520,6 @@ static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
break;
}
}
- va_end(args);
return TRUE;
}
@@ -552,9 +545,9 @@ METHOD(database_t, query, enumerator_t*,
INIT(enumerator,
.public = {
- .enumerate = (void*)mysql_enumerator_enumerate,
- .destroy = (void*)mysql_enumerator_destroy,
-
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _mysql_enumerator_enumerate,
+ .destroy = _mysql_enumerator_destroy,
},
.db = this,
.stmt = stmt,
diff --git a/src/libstrongswan/plugins/newhope/Makefile.in b/src/libstrongswan/plugins/newhope/Makefile.in
index 24857b3d6..a884b30b6 100644
--- a/src/libstrongswan/plugins/newhope/Makefile.in
+++ b/src/libstrongswan/plugins/newhope/Makefile.in
@@ -364,6 +364,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -386,6 +387,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/newhope/tests/Makefile.in b/src/libstrongswan/plugins/newhope/tests/Makefile.in
index 884a2eb6b..80fcf4dc5 100644
--- a/src/libstrongswan/plugins/newhope/tests/Makefile.in
+++ b/src/libstrongswan/plugins/newhope/tests/Makefile.in
@@ -356,6 +356,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -378,6 +379,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/nonce/Makefile.in b/src/libstrongswan/plugins/nonce/Makefile.in
index 8e04841cf..783eaf436 100644
--- a/src/libstrongswan/plugins/nonce/Makefile.in
+++ b/src/libstrongswan/plugins/nonce/Makefile.in
@@ -356,6 +356,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -378,6 +379,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/ntru/Makefile.in b/src/libstrongswan/plugins/ntru/Makefile.in
index c47f90bac..41ec4cec4 100644
--- a/src/libstrongswan/plugins/ntru/Makefile.in
+++ b/src/libstrongswan/plugins/ntru/Makefile.in
@@ -357,6 +357,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -379,6 +380,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/openssl/Makefile.in b/src/libstrongswan/plugins/openssl/Makefile.in
index 798ee5f26..9c0523652 100644
--- a/src/libstrongswan/plugins/openssl/Makefile.in
+++ b/src/libstrongswan/plugins/openssl/Makefile.in
@@ -365,6 +365,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -387,6 +388,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/openssl/openssl_crl.c b/src/libstrongswan/plugins/openssl/openssl_crl.c
index 20bac6be5..61cf3e884 100644
--- a/src/libstrongswan/plugins/openssl/openssl_crl.c
+++ b/src/libstrongswan/plugins/openssl/openssl_crl.c
@@ -142,8 +142,14 @@ typedef struct {
METHOD(enumerator_t, crl_enumerate, bool,
- crl_enumerator_t *this, chunk_t *serial, time_t *date, crl_reason_t *reason)
+ crl_enumerator_t *this, va_list args)
{
+ crl_reason_t *reason;
+ chunk_t *serial;
+ time_t *date;
+
+ VA_ARGS_VGET(args, serial, date, reason);
+
if (this->i < this->num)
{
X509_REVOKED *revoked;
@@ -188,7 +194,8 @@ METHOD(crl_t, create_enumerator, enumerator_t*,
INIT(enumerator,
.public = {
- .enumerate = (void*)_crl_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _crl_enumerate,
.destroy = (void*)free,
},
.stack = X509_CRL_get_REVOKED(this->crl),
diff --git a/src/libstrongswan/plugins/openssl/openssl_pkcs7.c b/src/libstrongswan/plugins/openssl/openssl_pkcs7.c
index 5752d96de..83ac8df5b 100644
--- a/src/libstrongswan/plugins/openssl/openssl_pkcs7.c
+++ b/src/libstrongswan/plugins/openssl/openssl_pkcs7.c
@@ -136,8 +136,12 @@ METHOD(enumerator_t, cert_destroy, void,
}
METHOD(enumerator_t, cert_enumerate, bool,
- cert_enumerator_t *this, certificate_t **out)
+ cert_enumerator_t *this, va_list args)
{
+ certificate_t **out;
+
+ VA_ARGS_VGET(args, out);
+
if (!this->certs)
{
return FALSE;
@@ -176,7 +180,8 @@ METHOD(pkcs7_t, create_cert_enumerator, enumerator_t*,
{
INIT(enumerator,
.public = {
- .enumerate = (void*)_cert_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _cert_enumerate,
.destroy = _cert_destroy,
},
.certs = CMS_get1_certs(this->cms),
@@ -320,8 +325,12 @@ static bool verify_digest(CMS_ContentInfo *cms, CMS_SignerInfo *si, int hash_oid
}
METHOD(enumerator_t, signature_enumerate, bool,
- signature_enumerator_t *this, auth_cfg_t **out)
+ signature_enumerator_t *this, va_list args)
{
+ auth_cfg_t **out;
+
+ VA_ARGS_VGET(args, out);
+
if (!this->signers)
{
return FALSE;
@@ -382,7 +391,8 @@ METHOD(container_t, create_signature_enumerator, enumerator_t*,
INIT(enumerator,
.public = {
- .enumerate = (void*)_signature_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _signature_enumerate,
.destroy = _signature_destroy,
},
.cms = this->cms,
diff --git a/src/libstrongswan/plugins/padlock/Makefile.in b/src/libstrongswan/plugins/padlock/Makefile.in
index 1fe0e7bb0..b71749589 100644
--- a/src/libstrongswan/plugins/padlock/Makefile.in
+++ b/src/libstrongswan/plugins/padlock/Makefile.in
@@ -358,6 +358,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -380,6 +381,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/pem/Makefile.in b/src/libstrongswan/plugins/pem/Makefile.in
index e3d7c776a..8ff3dd021 100644
--- a/src/libstrongswan/plugins/pem/Makefile.in
+++ b/src/libstrongswan/plugins/pem/Makefile.in
@@ -356,6 +356,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -378,6 +379,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/pem/pem_builder.c b/src/libstrongswan/plugins/pem/pem_builder.c
index 719a2a69e..ec90fb084 100644
--- a/src/libstrongswan/plugins/pem/pem_builder.c
+++ b/src/libstrongswan/plugins/pem/pem_builder.c
@@ -61,7 +61,7 @@ static bool find_boundary(char* tag, chunk_t *line)
if (!present("-----", line) ||
!present(tag, line) ||
- *line->ptr != ' ')
+ !line->len || *line->ptr != ' ')
{
return FALSE;
}
@@ -250,7 +250,7 @@ static status_t pem_to_bin(chunk_t *blob, bool *pgp)
{
continue;
}
- if (match("Proc-Type", &name) && *value.ptr == '4')
+ if (match("Proc-Type", &name) && value.len && *value.ptr == '4')
{
encrypted = TRUE;
}
@@ -306,7 +306,7 @@ static status_t pem_to_bin(chunk_t *blob, bool *pgp)
}
/* check for PGP armor checksum */
- if (*data.ptr == '=')
+ if (data.len && *data.ptr == '=')
{
*pgp = TRUE;
data.ptr++;
diff --git a/src/libstrongswan/plugins/pgp/Makefile.in b/src/libstrongswan/plugins/pgp/Makefile.in
index 552340230..3ffafd020 100644
--- a/src/libstrongswan/plugins/pgp/Makefile.in
+++ b/src/libstrongswan/plugins/pgp/Makefile.in
@@ -356,6 +356,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -378,6 +379,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/pkcs1/Makefile.in b/src/libstrongswan/plugins/pkcs1/Makefile.in
index 3cdc73102..cbf227680 100644
--- a/src/libstrongswan/plugins/pkcs1/Makefile.in
+++ b/src/libstrongswan/plugins/pkcs1/Makefile.in
@@ -357,6 +357,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -379,6 +380,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/pkcs11/Makefile.in b/src/libstrongswan/plugins/pkcs11/Makefile.in
index f4fffd3fa..ca7b5a8a9 100644
--- a/src/libstrongswan/plugins/pkcs11/Makefile.in
+++ b/src/libstrongswan/plugins/pkcs11/Makefile.in
@@ -360,6 +360,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -382,6 +383,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_creds.c b/src/libstrongswan/plugins/pkcs11/pkcs11_creds.c
index e65f3a06b..b1575540d 100644
--- a/src/libstrongswan/plugins/pkcs11/pkcs11_creds.c
+++ b/src/libstrongswan/plugins/pkcs11/pkcs11_creds.c
@@ -153,30 +153,32 @@ static bool load_certificates(private_pkcs11_creds_t *this)
return TRUE;
}
-/**
- * filter function for certs enumerator
- */
-static bool certs_filter(identification_t *id,
- certificate_t **in, certificate_t **out)
+CALLBACK(certs_filter, bool,
+ identification_t *id, enumerator_t *orig, va_list args)
{
public_key_t *public;
- certificate_t *cert = *in;
+ certificate_t *cert, **out;
- if (id == NULL || cert->has_subject(cert, id))
- {
- *out = *in;
- return TRUE;
- }
- public = cert->get_public_key(cert);
- if (public)
+ VA_ARGS_VGET(args, out);
+
+ while (orig->enumerate(orig, &cert))
{
- if (public->has_fingerprint(public, id->get_encoding(id)))
+ if (id == NULL || cert->has_subject(cert, id))
{
- public->destroy(public);
- *out = *in;
+ *out = cert;
return TRUE;
}
- public->destroy(public);
+ public = cert->get_public_key(cert);
+ if (public)
+ {
+ if (public->has_fingerprint(public, id->get_encoding(id)))
+ {
+ public->destroy(public);
+ *out = cert;
+ return TRUE;
+ }
+ public->destroy(public);
+ }
}
return FALSE;
}
@@ -199,7 +201,7 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
{
inner = this->untrusted->create_enumerator(this->untrusted);
}
- return enumerator_create_filter(inner, (void*)certs_filter, id, NULL);
+ return enumerator_create_filter(inner, certs_filter, id, NULL);
}
METHOD(pkcs11_creds_t, get_library, pkcs11_library_t*,
diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_library.c b/src/libstrongswan/plugins/pkcs11/pkcs11_library.c
index dc8a1f17a..89ae1969e 100644
--- a/src/libstrongswan/plugins/pkcs11/pkcs11_library.c
+++ b/src/libstrongswan/plugins/pkcs11/pkcs11_library.c
@@ -719,12 +719,14 @@ static bool get_attributes(object_enumerator_t *this, CK_OBJECT_HANDLE object)
}
METHOD(enumerator_t, object_enumerate, bool,
- object_enumerator_t *this, CK_OBJECT_HANDLE *out)
+ object_enumerator_t *this, va_list args)
{
- CK_OBJECT_HANDLE object;
+ CK_OBJECT_HANDLE object, *out;
CK_ULONG found;
CK_RV rv;
+ VA_ARGS_VGET(args, out);
+
if (!this->object)
{
rv = this->lib->f->C_FindObjects(this->session, &object, 1, &found);
@@ -786,7 +788,8 @@ METHOD(pkcs11_library_t, create_object_enumerator, enumerator_t*,
INIT(enumerator,
.public = {
- .enumerate = (void*)_object_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _object_enumerate,
.destroy = _object_destroy,
},
.session = session,
@@ -806,7 +809,8 @@ METHOD(pkcs11_library_t, create_object_attr_enumerator, enumerator_t*,
INIT(enumerator,
.public = {
- .enumerate = (void*)_object_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _object_enumerate,
.destroy = _object_destroy,
},
.session = session,
@@ -838,11 +842,14 @@ typedef struct {
} mechanism_enumerator_t;
METHOD(enumerator_t, enumerate_mech, bool,
- mechanism_enumerator_t *this, CK_MECHANISM_TYPE* type,
- CK_MECHANISM_INFO *info)
+ mechanism_enumerator_t *this, va_list args)
{
+ CK_MECHANISM_INFO *info;
+ CK_MECHANISM_TYPE *type;
CK_RV rv;
+ VA_ARGS_VGET(args, type, info);
+
if (this->current >= this->count)
{
return FALSE;
@@ -876,7 +883,8 @@ METHOD(pkcs11_library_t, create_mechanism_enumerator, enumerator_t*,
INIT(enumerator,
.public = {
- .enumerate = (void*)_enumerate_mech,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate_mech,
.destroy = _destroy_mech,
},
.lib = &this->public,
diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_manager.c b/src/libstrongswan/plugins/pkcs11/pkcs11_manager.c
index 96c4a180d..31bcb0d25 100644
--- a/src/libstrongswan/plugins/pkcs11/pkcs11_manager.c
+++ b/src/libstrongswan/plugins/pkcs11/pkcs11_manager.c
@@ -265,8 +265,13 @@ typedef struct {
} token_enumerator_t;
METHOD(enumerator_t, enumerate_token, bool,
- token_enumerator_t *this, pkcs11_library_t **out, CK_SLOT_ID *slot)
+ token_enumerator_t *this, va_list args)
{
+ pkcs11_library_t **out;
+ CK_SLOT_ID *slot;
+
+ VA_ARGS_VGET(args, out, slot);
+
if (this->current >= this->count)
{
free(this->slots);
@@ -301,7 +306,8 @@ METHOD(pkcs11_manager_t, create_token_enumerator, enumerator_t*,
INIT(enumerator,
.public = {
- .enumerate = (void*)_enumerate_token,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate_token,
.destroy = _destroy_token,
},
.inner = this->libs->create_enumerator(this->libs),
diff --git a/src/libstrongswan/plugins/pkcs12/Makefile.in b/src/libstrongswan/plugins/pkcs12/Makefile.in
index 72996f164..73f15d26c 100644
--- a/src/libstrongswan/plugins/pkcs12/Makefile.in
+++ b/src/libstrongswan/plugins/pkcs12/Makefile.in
@@ -357,6 +357,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -379,6 +380,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/pkcs7/Makefile.in b/src/libstrongswan/plugins/pkcs7/Makefile.in
index 6224b1b92..3bf44de30 100644
--- a/src/libstrongswan/plugins/pkcs7/Makefile.in
+++ b/src/libstrongswan/plugins/pkcs7/Makefile.in
@@ -359,6 +359,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -381,6 +382,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/pkcs7/pkcs7_signed_data.c b/src/libstrongswan/plugins/pkcs7/pkcs7_signed_data.c
index d224ef3aa..413c3fff5 100644
--- a/src/libstrongswan/plugins/pkcs7/pkcs7_signed_data.c
+++ b/src/libstrongswan/plugins/pkcs7/pkcs7_signed_data.c
@@ -179,7 +179,7 @@ typedef struct {
} signature_enumerator_t;
METHOD(enumerator_t, enumerate, bool,
- signature_enumerator_t *this, auth_cfg_t **out)
+ signature_enumerator_t *this, va_list args)
{
signerinfo_t *info;
signature_scheme_t scheme;
@@ -187,11 +187,13 @@ METHOD(enumerator_t, enumerate, bool,
enumerator_t *enumerator;
certificate_t *cert;
public_key_t *key;
- auth_cfg_t *auth;
+ auth_cfg_t *auth, **out;
chunk_t chunk, hash, content;
hasher_t *hasher;
bool valid;
+ VA_ARGS_VGET(args, out);
+
while (this->inner->enumerate(this->inner, &info))
{
/* clean up previous round */
@@ -300,7 +302,8 @@ METHOD(container_t, create_signature_enumerator, enumerator_t*,
INIT(enumerator,
.public = {
- .enumerate = (void*)_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _enumerate,
.destroy = _enumerator_destroy,
},
.inner = this->signerinfos->create_enumerator(this->signerinfos),
diff --git a/src/libstrongswan/plugins/pkcs8/Makefile.in b/src/libstrongswan/plugins/pkcs8/Makefile.in
index 475de08fb..2066d8792 100644
--- a/src/libstrongswan/plugins/pkcs8/Makefile.in
+++ b/src/libstrongswan/plugins/pkcs8/Makefile.in
@@ -356,6 +356,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -378,6 +379,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/plugin_constructors.py b/src/libstrongswan/plugins/plugin_constructors.py
new file mode 100644
index 000000000..d9c40e383
--- /dev/null
+++ b/src/libstrongswan/plugins/plugin_constructors.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2017 Tobias Brunner
+# HSR Hochschule fuer Technik Rapperswil
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+
+import sys
+from argparse import ArgumentParser
+
+def generate_output(plugins):
+ """Generate a source file containing plugin constructor registrations"""
+ print("/**")
+ print(" * Register plugin constructors for static libraries")
+ print(" * Created by {0}".format(__file__))
+ print(" */")
+ print("")
+ print("#include <plugins/plugin.h>")
+ print("#include <plugins/plugin_loader.h>")
+ print("")
+
+ for plugin in plugins:
+ print("plugin_t *{0}_plugin_create();".format(plugin.replace('-', '_')))
+
+ print("")
+ print("static void register_plugins() __attribute__ ((constructor));")
+ print("static void register_plugins()")
+ print("{")
+
+ for plugin in plugins:
+ print(' plugin_constructor_register("{0}", {1}_plugin_create);'.format(plugin, plugin.replace('-', '_')))
+
+ print("}")
+
+ print("")
+ print("static void unregister_plugins() __attribute__ ((destructor));")
+ print("static void unregister_plugins()")
+ print("{")
+
+ for plugin in plugins:
+ print(' plugin_constructor_register("{0}", NULL);'.format(plugin))
+
+ print("}")
+ print("")
+
+parser = ArgumentParser(description = "Generate constructor registration for a list of plugins")
+parser.add_argument('plugins', metavar="plugin", nargs="*",
+ help = "name of a plugin for which to generate constructor registration")
+
+
+args = parser.parse_args()
+generate_output(args.plugins);
diff --git a/src/libstrongswan/plugins/plugin_loader.c b/src/libstrongswan/plugins/plugin_loader.c
index e4698fac0..42d443b7a 100644
--- a/src/libstrongswan/plugins/plugin_loader.c
+++ b/src/libstrongswan/plugins/plugin_loader.c
@@ -40,6 +40,13 @@ typedef struct registered_feature_t registered_feature_t;
typedef struct provided_feature_t provided_feature_t;
typedef struct plugin_entry_t plugin_entry_t;
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+/**
+ * Statically registered constructors
+ */
+static hashtable_t *plugin_constructors = NULL;
+#endif
+
/**
* private data of plugin_loader
*/
@@ -298,6 +305,46 @@ static plugin_t *static_features_create(const char *name,
return &this->public;
}
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+/*
+ * Described in header.
+ */
+void plugin_constructor_register(char *name, void *constructor)
+{
+ bool old = FALSE;
+
+ if (lib && lib->leak_detective)
+ {
+ old = lib->leak_detective->set_state(lib->leak_detective, FALSE);
+ }
+
+ if (!plugin_constructors)
+ {
+ chunk_hash_seed();
+ plugin_constructors = hashtable_create(hashtable_hash_str,
+ hashtable_equals_str, 32);
+ }
+ if (constructor)
+ {
+ plugin_constructors->put(plugin_constructors, name, constructor);
+ }
+ else
+ {
+ plugin_constructors->remove(plugin_constructors, name);
+ if (!plugin_constructors->get_count(plugin_constructors))
+ {
+ plugin_constructors->destroy(plugin_constructors);
+ plugin_constructors = NULL;
+ }
+ }
+
+ if (lib && lib->leak_detective)
+ {
+ lib->leak_detective->set_state(lib->leak_detective, old);
+ }
+}
+#endif
+
/**
* create a plugin
* returns: NOT_FOUND, if the constructor was not found
@@ -309,7 +356,7 @@ static status_t create_plugin(private_plugin_loader_t *this, void *handle,
{
char create[128];
plugin_t *plugin;
- plugin_constructor_t constructor;
+ plugin_constructor_t constructor = NULL;
if (snprintf(create, sizeof(create), "%s_plugin_create",
name) >= sizeof(create))
@@ -317,8 +364,17 @@ static status_t create_plugin(private_plugin_loader_t *this, void *handle,
return FAILED;
}
translate(create, "-", "_");
- constructor = dlsym(handle, create);
- if (constructor == NULL)
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+ if (plugin_constructors)
+ {
+ constructor = plugin_constructors->get(plugin_constructors, name);
+ }
+ if (!constructor)
+#endif
+ {
+ constructor = dlsym(handle, create);
+ }
+ if (!constructor)
{
return NOT_FOUND;
}
@@ -409,34 +465,48 @@ static plugin_entry_t *load_plugin(private_plugin_loader_t *this, char *name,
return entry;
}
-/**
- * Convert enumerated provided_feature_t to plugin_feature_t
- */
-static bool feature_filter(void *null, provided_feature_t **provided,
- plugin_feature_t **feature)
+CALLBACK(feature_filter, bool,
+ void *null, enumerator_t *orig, va_list args)
{
- *feature = (*provided)->feature;
- return (*provided)->loaded;
+ provided_feature_t *provided;
+ plugin_feature_t **feature;
+
+ VA_ARGS_VGET(args, feature);
+
+ while (orig->enumerate(orig, &provided))
+ {
+ if (provided->loaded)
+ {
+ *feature = provided->feature;
+ return TRUE;
+ }
+ }
+ return FALSE;
}
-/**
- * Convert enumerated entries to plugin_t
- */
-static bool plugin_filter(void *null, plugin_entry_t **entry, plugin_t **plugin,
- void *in, linked_list_t **list)
+CALLBACK(plugin_filter, bool,
+ void *null, enumerator_t *orig, va_list args)
{
- plugin_entry_t *this = *entry;
+ plugin_entry_t *entry;
+ linked_list_t **list;
+ plugin_t **plugin;
+
+ VA_ARGS_VGET(args, plugin, list);
- *plugin = this->plugin;
- if (list)
+ if (orig->enumerate(orig, &entry))
{
- enumerator_t *features;
- features = enumerator_create_filter(
- this->features->create_enumerator(this->features),
- (void*)feature_filter, NULL, NULL);
- *list = linked_list_create_from_enumerator(features);
+ *plugin = entry->plugin;
+ if (list)
+ {
+ enumerator_t *features;
+ features = enumerator_create_filter(
+ entry->features->create_enumerator(entry->features),
+ feature_filter, NULL, NULL);
+ *list = linked_list_create_from_enumerator(features);
+ }
+ return TRUE;
}
- return TRUE;
+ return FALSE;
}
METHOD(plugin_loader_t, create_plugin_enumerator, enumerator_t*,
@@ -444,7 +514,7 @@ METHOD(plugin_loader_t, create_plugin_enumerator, enumerator_t*,
{
return enumerator_create_filter(
this->plugins->create_enumerator(this->plugins),
- (void*)plugin_filter, NULL, NULL);
+ plugin_filter, NULL, NULL);
}
METHOD(plugin_loader_t, has_feature, bool,
@@ -536,18 +606,14 @@ static void load_provided(private_plugin_loader_t *this,
provided_feature_t *provided,
int level);
-/**
- * Used to find a loaded feature
- */
-static bool is_feature_loaded(provided_feature_t *item)
+CALLBACK(is_feature_loaded, bool,
+ provided_feature_t *item, va_list args)
{
return item->loaded;
}
-/**
- * Used to find a loadable feature
- */
-static bool is_feature_loadable(provided_feature_t *item)
+CALLBACK(is_feature_loadable, bool,
+ provided_feature_t *item, va_list args)
{
return !item->loading && !item->loaded && !item->failed;
}
@@ -560,8 +626,7 @@ static bool loaded_feature_matches(registered_feature_t *a,
{
if (plugin_feature_matches(a->feature, b->feature))
{
- return b->plugins->find_first(b->plugins, (void*)is_feature_loaded,
- NULL) == SUCCESS;
+ return b->plugins->find_first(b->plugins, is_feature_loaded, NULL);
}
return FALSE;
}
@@ -574,8 +639,7 @@ static bool loadable_feature_equals(registered_feature_t *a,
{
if (plugin_feature_equals(a->feature, b->feature))
{
- return b->plugins->find_first(b->plugins, (void*)is_feature_loadable,
- NULL) == SUCCESS;
+ return b->plugins->find_first(b->plugins, is_feature_loadable, NULL);
}
return FALSE;
}
@@ -588,8 +652,7 @@ static bool loadable_feature_matches(registered_feature_t *a,
{
if (plugin_feature_matches(a->feature, b->feature))
{
- return b->plugins->find_first(b->plugins, (void*)is_feature_loadable,
- NULL) == SUCCESS;
+ return b->plugins->find_first(b->plugins, is_feature_loadable, NULL);
}
return FALSE;
}
@@ -674,9 +737,11 @@ static bool load_dependencies(private_plugin_loader_t *this,
if (!find_compatible_feature(this, &provided->feature[i]))
{
- char *name, *provide, *depend;
bool soft = provided->feature[i].kind == FEATURE_SDEPEND;
+#ifndef USE_FUZZING
+ char *name, *provide, *depend;
+
name = provided->entry->plugin->get_name(provided->entry->plugin);
provide = plugin_feature_get_string(&provided->feature[0]);
depend = plugin_feature_get_string(&provided->feature[i]);
@@ -697,6 +762,8 @@ static bool load_dependencies(private_plugin_loader_t *this,
}
free(provide);
free(depend);
+#endif /* !USE_FUZZING */
+
if (soft)
{ /* it's ok if we can't resolve soft dependencies */
continue;
@@ -716,8 +783,6 @@ static void load_feature(private_plugin_loader_t *this,
{
if (load_dependencies(this, provided, level))
{
- char *name, *provide;
-
if (plugin_feature_load(provided->entry->plugin, provided->feature,
provided->reg))
{
@@ -727,6 +792,9 @@ static void load_feature(private_plugin_loader_t *this,
return;
}
+#ifndef USE_FUZZING
+ char *name, *provide;
+
name = provided->entry->plugin->get_name(provided->entry->plugin);
provide = plugin_feature_get_string(&provided->feature[0]);
if (provided->entry->critical)
@@ -740,6 +808,7 @@ static void load_feature(private_plugin_loader_t *this,
provide, name);
}
free(provide);
+#endif /* !USE_FUZZING */
}
else
{ /* TODO: we could check the current level and set a different flag when
@@ -759,13 +828,16 @@ static void load_provided(private_plugin_loader_t *this,
provided_feature_t *provided,
int level)
{
- char *name, *provide;
int indent = level * 2;
if (provided->loaded || provided->failed)
{
return;
}
+
+#ifndef USE_FUZZING
+ char *name, *provide;
+
name = provided->entry->plugin->get_name(provided->entry->plugin);
provide = plugin_feature_get_string(provided->feature);
if (provided->loading)
@@ -778,6 +850,12 @@ static void load_provided(private_plugin_loader_t *this,
DBG3(DBG_LIB, "%*sloading feature %s in plugin '%s'",
indent, "", provide, name);
free(provide);
+#else
+ if (provided->loading)
+ {
+ return;
+ }
+#endif /* USE_FUZZING */
provided->loading = TRUE;
load_feature(this, provided, level + 1);
@@ -926,8 +1004,8 @@ static void purge_plugins(private_plugin_loader_t *this)
{ /* feature interface not supported */
continue;
}
- if (entry->features->find_first(entry->features,
- (void*)is_feature_loaded, NULL) != SUCCESS)
+ if (!entry->features->find_first(entry->features, is_feature_loaded,
+ NULL))
{
DBG2(DBG_LIB, "unloading plugin '%s' without loaded features",
entry->plugin->get_name(entry->plugin));
@@ -977,6 +1055,15 @@ static bool find_plugin(char *path, char *name, char *buf, char **file)
return FALSE;
}
+CALLBACK(find_plugin_cb, bool,
+ char *path, va_list args)
+{
+ char *name, *buf, **file;
+
+ VA_ARGS_VGET(args, name, buf, file);
+ return find_plugin(path, name, buf, file);
+}
+
/**
* Used to sort plugins by priority
*/
@@ -1024,14 +1111,20 @@ static int plugin_priority_cmp(const plugin_priority_t *a,
return diff;
}
-/**
- * Convert enumerated plugin_priority_t to a plugin name
- */
-static bool plugin_priority_filter(void *null, plugin_priority_t **prio,
- char **name)
+CALLBACK(plugin_priority_filter, bool,
+ void *null, enumerator_t *orig, va_list args)
{
- *name = (*prio)->name;
- return TRUE;
+ plugin_priority_t *prio;
+ char **name;
+
+ VA_ARGS_VGET(args, name);
+
+ if (orig->enumerate(orig, &prio))
+ {
+ *name = prio->name;
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -1071,7 +1164,7 @@ static char *modular_pluginlist(char *list)
else
{
enumerator = enumerator_create_filter(array_create_enumerator(given),
- (void*)plugin_priority_filter, NULL, NULL);
+ plugin_priority_filter, NULL, NULL);
load_def = TRUE;
}
while (enumerator->enumerate(enumerator, &plugin))
@@ -1153,8 +1246,8 @@ METHOD(plugin_loader_t, load_plugins, bool,
}
if (this->paths)
{
- this->paths->find_first(this->paths, (void*)find_plugin, NULL,
- token, buf, &file);
+ this->paths->find_first(this->paths, find_plugin_cb, NULL, token,
+ buf, &file);
}
if (!file)
{
diff --git a/src/libstrongswan/plugins/plugin_loader.h b/src/libstrongswan/plugins/plugin_loader.h
index 6be6a909c..92a860615 100644
--- a/src/libstrongswan/plugins/plugin_loader.h
+++ b/src/libstrongswan/plugins/plugin_loader.h
@@ -168,4 +168,14 @@ plugin_loader_t *plugin_loader_create();
*/
void plugin_loader_add_plugindirs(char *basedir, char *plugins);
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+/**
+ * Register a plugin constructor in case of static builds.
+ *
+ * @param name name of the plugin
+ * @param constructor constructor to register (set to NULL to unregister)
+ */
+void plugin_constructor_register(char *name, void *constructor);
+#endif
+
#endif /** PLUGIN_LOADER_H_ @}*/
diff --git a/src/libstrongswan/plugins/pubkey/Makefile.in b/src/libstrongswan/plugins/pubkey/Makefile.in
index 4b0b13e16..04888cde2 100644
--- a/src/libstrongswan/plugins/pubkey/Makefile.in
+++ b/src/libstrongswan/plugins/pubkey/Makefile.in
@@ -357,6 +357,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -379,6 +380,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/random/Makefile.in b/src/libstrongswan/plugins/random/Makefile.in
index 1cf00a586..940c5572a 100644
--- a/src/libstrongswan/plugins/random/Makefile.in
+++ b/src/libstrongswan/plugins/random/Makefile.in
@@ -357,6 +357,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -379,6 +380,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/rc2/Makefile.in b/src/libstrongswan/plugins/rc2/Makefile.in
index a57e15b64..c432cf810 100644
--- a/src/libstrongswan/plugins/rc2/Makefile.in
+++ b/src/libstrongswan/plugins/rc2/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/rdrand/Makefile.in b/src/libstrongswan/plugins/rdrand/Makefile.in
index a5d76c109..849c89630 100644
--- a/src/libstrongswan/plugins/rdrand/Makefile.in
+++ b/src/libstrongswan/plugins/rdrand/Makefile.in
@@ -357,6 +357,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -379,6 +380,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/revocation/Makefile.in b/src/libstrongswan/plugins/revocation/Makefile.in
index cfbbcd8ad..5840c7dd0 100644
--- a/src/libstrongswan/plugins/revocation/Makefile.in
+++ b/src/libstrongswan/plugins/revocation/Makefile.in
@@ -358,6 +358,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -380,6 +381,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/sha1/Makefile.in b/src/libstrongswan/plugins/sha1/Makefile.in
index 8e3301e6f..fa596e6f4 100644
--- a/src/libstrongswan/plugins/sha1/Makefile.in
+++ b/src/libstrongswan/plugins/sha1/Makefile.in
@@ -356,6 +356,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -378,6 +379,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/sha2/Makefile.in b/src/libstrongswan/plugins/sha2/Makefile.in
index 045d6e0cc..6e3d6a390 100644
--- a/src/libstrongswan/plugins/sha2/Makefile.in
+++ b/src/libstrongswan/plugins/sha2/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/sha3/Makefile.in b/src/libstrongswan/plugins/sha3/Makefile.in
index 9fc0a1a1f..2c249343c 100644
--- a/src/libstrongswan/plugins/sha3/Makefile.in
+++ b/src/libstrongswan/plugins/sha3/Makefile.in
@@ -356,6 +356,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -378,6 +379,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/soup/Makefile.in b/src/libstrongswan/plugins/soup/Makefile.in
index 517900486..02e398729 100644
--- a/src/libstrongswan/plugins/soup/Makefile.in
+++ b/src/libstrongswan/plugins/soup/Makefile.in
@@ -356,6 +356,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -378,6 +379,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/sqlite/Makefile.in b/src/libstrongswan/plugins/sqlite/Makefile.in
index 8ffc4aae0..5e23cb91c 100644
--- a/src/libstrongswan/plugins/sqlite/Makefile.in
+++ b/src/libstrongswan/plugins/sqlite/Makefile.in
@@ -358,6 +358,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -380,6 +381,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/sqlite/sqlite_database.c b/src/libstrongswan/plugins/sqlite/sqlite_database.c
index 0a35e3017..9f874212e 100644
--- a/src/libstrongswan/plugins/sqlite/sqlite_database.c
+++ b/src/libstrongswan/plugins/sqlite/sqlite_database.c
@@ -174,10 +174,8 @@ typedef struct {
private_sqlite_database_t *database;
} sqlite_enumerator_t;
-/**
- * destroy a sqlite enumerator
- */
-static void sqlite_enumerator_destroy(sqlite_enumerator_t *this)
+METHOD(enumerator_t, sqlite_enumerator_destroy, void,
+ sqlite_enumerator_t *this)
{
sqlite3_finalize(this->stmt);
if (!is_threadsave())
@@ -188,13 +186,10 @@ static void sqlite_enumerator_destroy(sqlite_enumerator_t *this)
free(this);
}
-/**
- * Implementation of database.query().enumerate
- */
-static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...)
+METHOD(enumerator_t, sqlite_enumerator_enumerate, bool,
+ sqlite_enumerator_t *this, va_list args)
{
int i;
- va_list args;
switch (sqlite3_step(this->stmt))
{
@@ -207,7 +202,7 @@ static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...)
case SQLITE_DONE:
return FALSE;
}
- va_start(args, this);
+
for (i = 0; i < this->count; i++)
{
switch (this->columns[i])
@@ -245,11 +240,9 @@ static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...)
}
default:
DBG1(DBG_LIB, "invalid result type supplied");
- va_end(args);
return FALSE;
}
}
- va_end(args);
return TRUE;
}
@@ -270,13 +263,17 @@ METHOD(database_t, query, enumerator_t*,
stmt = run(this, sql, &args);
if (stmt)
{
- enumerator = malloc_thing(sqlite_enumerator_t);
- enumerator->public.enumerate = (void*)sqlite_enumerator_enumerate;
- enumerator->public.destroy = (void*)sqlite_enumerator_destroy;
- enumerator->stmt = stmt;
- enumerator->count = sqlite3_column_count(stmt);
+ INIT(enumerator,
+ .public = {
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _sqlite_enumerator_enumerate,
+ .destroy = _sqlite_enumerator_destroy,
+ },
+ .stmt = stmt,
+ .count = sqlite3_column_count(stmt),
+ .database = this,
+ );
enumerator->columns = malloc(sizeof(db_type_t) * enumerator->count);
- enumerator->database = this;
for (i = 0; i < enumerator->count; i++)
{
enumerator->columns[i] = va_arg(args, db_type_t);
diff --git a/src/libstrongswan/plugins/sshkey/Makefile.in b/src/libstrongswan/plugins/sshkey/Makefile.in
index 8528b8707..a6663999d 100644
--- a/src/libstrongswan/plugins/sshkey/Makefile.in
+++ b/src/libstrongswan/plugins/sshkey/Makefile.in
@@ -358,6 +358,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -380,6 +381,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/test_vectors/Makefile.in b/src/libstrongswan/plugins/test_vectors/Makefile.in
index 27741dd15..33c5720a4 100644
--- a/src/libstrongswan/plugins/test_vectors/Makefile.in
+++ b/src/libstrongswan/plugins/test_vectors/Makefile.in
@@ -376,6 +376,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -398,6 +399,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/unbound/Makefile.in b/src/libstrongswan/plugins/unbound/Makefile.in
index 4822283c3..15c8c27cc 100644
--- a/src/libstrongswan/plugins/unbound/Makefile.in
+++ b/src/libstrongswan/plugins/unbound/Makefile.in
@@ -358,6 +358,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -380,6 +381,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/winhttp/Makefile.in b/src/libstrongswan/plugins/winhttp/Makefile.in
index 9a26a987c..b417d6e66 100644
--- a/src/libstrongswan/plugins/winhttp/Makefile.in
+++ b/src/libstrongswan/plugins/winhttp/Makefile.in
@@ -358,6 +358,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -380,6 +381,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/x509/Makefile.in b/src/libstrongswan/plugins/x509/Makefile.in
index 8d7f9a810..e1ed6b7ee 100644
--- a/src/libstrongswan/plugins/x509/Makefile.in
+++ b/src/libstrongswan/plugins/x509/Makefile.in
@@ -357,6 +357,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -379,6 +380,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/x509/x509_ac.c b/src/libstrongswan/plugins/x509/x509_ac.c
index aea8eb53d..ba459288b 100644
--- a/src/libstrongswan/plugins/x509/x509_ac.c
+++ b/src/libstrongswan/plugins/x509/x509_ac.c
@@ -1,9 +1,8 @@
/*
* Copyright (C) 2002 Ueli Galizzi, Ariane Seiler
* Copyright (C) 2003 Martin Berner, Lukas Suter
- * Copyright (C) 2002-2014 Andreas Steffen
+ * Copyright (C) 2002-2017 Andreas Steffen
* Copyright (C) 2009 Martin Willi
- *
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -177,7 +176,7 @@ static chunk_t ASN1_noRevAvail_ext = chunk_from_chars(
/**
* declaration of function implemented in x509_cert.c
*/
-extern void x509_parse_generalNames(chunk_t blob, int level0, bool implicit,
+extern bool x509_parse_generalNames(chunk_t blob, int level0, bool implicit,
linked_list_t *list);
/**
* parses a directoryName
@@ -191,7 +190,11 @@ static bool parse_directoryName(chunk_t blob, int level, bool implicit,
linked_list_t *list;
list = linked_list_create();
- x509_parse_generalNames(blob, level, implicit, list);
+ if (!x509_parse_generalNames(blob, level, implicit, list))
+ {
+ list->destroy(list);
+ return FALSE;
+ }
enumerator = list->create_enumerator(list);
while (enumerator->enumerate(enumerator, &directoryName))
@@ -801,20 +804,27 @@ METHOD(ac_t, get_authKeyIdentifier, chunk_t,
return this->authKeyIdentifier;
}
-/**
- * Filter function for attribute enumeration
- */
-static bool attr_filter(void *null, group_t **in, ac_group_type_t *type,
- void *in2, chunk_t *out)
+CALLBACK(attr_filter, bool,
+ void *null, enumerator_t *orig, va_list args)
{
- if ((*in)->type == AC_GROUP_TYPE_STRING &&
- !chunk_printable((*in)->value, NULL, 0))
- { /* skip non-printable strings */
- return FALSE;
+ group_t *group;
+ ac_group_type_t *type;
+ chunk_t *out;
+
+ VA_ARGS_VGET(args, type, out);
+
+ while (orig->enumerate(orig, &group))
+ {
+ if (group->type == AC_GROUP_TYPE_STRING &&
+ !chunk_printable(group->value, NULL, 0))
+ { /* skip non-printable strings */
+ continue;
+ }
+ *type = group->type;
+ *out = group->value;
+ return TRUE;
}
- *type = (*in)->type;
- *out = (*in)->value;
- return TRUE;
+ return FALSE;
}
METHOD(ac_t, create_group_enumerator, enumerator_t*,
@@ -822,7 +832,7 @@ METHOD(ac_t, create_group_enumerator, enumerator_t*,
{
return enumerator_create_filter(
this->groups->create_enumerator(this->groups),
- (void*)attr_filter, NULL, NULL);
+ attr_filter, NULL, NULL);
}
METHOD(certificate_t, get_type, certificate_type_t,
diff --git a/src/libstrongswan/plugins/x509/x509_cert.c b/src/libstrongswan/plugins/x509/x509_cert.c
index b77c5db4d..974e687f9 100644
--- a/src/libstrongswan/plugins/x509/x509_cert.c
+++ b/src/libstrongswan/plugins/x509/x509_cert.c
@@ -2,10 +2,10 @@
* Copyright (C) 2000 Andreas Hess, Patric Lichtsteiner, Roger Wegmann
* Copyright (C) 2001 Marco Bertossa, Andreas Schleiss
* Copyright (C) 2002 Mario Strasser
- * Copyright (C) 2000-2006 Andreas Steffen
+ * Copyright (C) 2000-2017 Andreas Steffen
* Copyright (C) 2006-2009 Martin Willi
* Copyright (C) 2008 Tobias Brunner
- * Hochschule fuer Technik Rapperswil
+ * HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -218,6 +218,29 @@ struct private_x509_cert_t {
};
/**
+ * Convert a generalName to a string
+ */
+static bool gn_to_string(identification_t *id, char **uri)
+{
+ int len;
+
+#ifdef USE_FUZZING
+ chunk_t proper;
+ chunk_printable(id->get_encoding(id), &proper, '?');
+ len = asprintf(uri, "%.*s", (int)proper.len, proper.ptr);
+ chunk_free(&proper);
+#else
+ len = asprintf(uri, "%Y", id);
+#endif
+ if (!len)
+ {
+ free(*uri);
+ return FALSE;
+ }
+ return len > 0;
+}
+
+/**
* Destroy a CertificateDistributionPoint
*/
static void crl_uri_destroy(x509_cdp_t *this)
@@ -280,13 +303,14 @@ static const asn1Object_t basicConstraintsObjects[] = {
/**
* Extracts the basicConstraints extension
*/
-static void parse_basicConstraints(chunk_t blob, int level0,
+static bool parse_basicConstraints(chunk_t blob, int level0,
private_x509_cert_t *this)
{
asn1_parser_t *parser;
chunk_t object;
int objectID;
bool isCA = FALSE;
+ bool success;
parser = asn1_parser_create(basicConstraintsObjects, blob);
parser->set_top_level(parser, level0);
@@ -313,7 +337,10 @@ static void parse_basicConstraints(chunk_t blob, int level0,
break;
}
}
+ success = parser->success(parser);
parser->destroy(parser);
+
+ return success;
}
/**
@@ -502,11 +529,14 @@ static const asn1Object_t generalNamesObjects[] = {
/**
* Extracts one or several GNs and puts them into a chained list
*/
-void x509_parse_generalNames(chunk_t blob, int level0, bool implicit, linked_list_t *list)
+bool x509_parse_generalNames(chunk_t blob, int level0, bool implicit,
+ linked_list_t *list)
{
asn1_parser_t *parser;
chunk_t object;
+ identification_t *gn;
int objectID;
+ bool success = FALSE;
parser = asn1_parser_create(generalNamesObjects, blob);
parser->set_top_level(parser, level0);
@@ -516,16 +546,20 @@ void x509_parse_generalNames(chunk_t blob, int level0, bool implicit, linked_lis
{
if (objectID == GENERAL_NAMES_GN)
{
- identification_t *gn = parse_generalName(object,
- parser->get_level(parser)+1);
-
- if (gn)
+ gn = parse_generalName(object, parser->get_level(parser)+1);
+ if (!gn)
{
- list->insert_last(list, (void *)gn);
+ goto end;
}
+ list->insert_last(list, (void *)gn);
}
}
+ success = parser->success(parser);
+
+end:
parser->destroy(parser);
+
+ return success;
}
/**
@@ -579,6 +613,7 @@ chunk_t x509_parse_authorityKeyIdentifier(chunk_t blob, int level0,
}
}
parser->destroy(parser);
+
return authKeyIdentifier;
}
@@ -599,13 +634,14 @@ static const asn1Object_t authInfoAccessObjects[] = {
/**
* Extracts an authorityInfoAcess location
*/
-static void parse_authorityInfoAccess(chunk_t blob, int level0,
+static bool parse_authorityInfoAccess(chunk_t blob, int level0,
private_x509_cert_t *this)
{
asn1_parser_t *parser;
chunk_t object;
int objectID;
int accessMethod = OID_UNKNOWN;
+ bool success = FALSE;
parser = asn1_parser_create(authInfoAccessObjects, blob);
parser->set_top_level(parser, level0);
@@ -636,7 +672,7 @@ static void parse_authorityInfoAccess(chunk_t blob, int level0,
}
DBG2(DBG_ASN, " '%Y'", id);
if (accessMethod == OID_OCSP &&
- asprintf(&uri, "%Y", id) > 0)
+ gn_to_string(id, &uri))
{
this->ocsp_uris->insert_last(this->ocsp_uris, uri);
}
@@ -653,9 +689,12 @@ static void parse_authorityInfoAccess(chunk_t blob, int level0,
break;
}
}
+ success = parser->success(parser);
end:
parser->destroy(parser);
+
+ return success;
}
/**
@@ -726,12 +765,13 @@ static const asn1Object_t extendedKeyUsageObjects[] = {
/**
* Extracts extendedKeyUsage OIDs
*/
-static void parse_extendedKeyUsage(chunk_t blob, int level0,
+static bool parse_extendedKeyUsage(chunk_t blob, int level0,
private_x509_cert_t *this)
{
asn1_parser_t *parser;
chunk_t object;
int objectID;
+ bool success;
parser = asn1_parser_create(extendedKeyUsageObjects, blob);
parser->set_top_level(parser, level0);
@@ -762,27 +802,30 @@ static void parse_extendedKeyUsage(chunk_t blob, int level0,
}
}
}
+ success = parser->success(parser);
parser->destroy(parser);
+
+ return success;
}
/**
* ASN.1 definition of crlDistributionPoints
*/
static const asn1Object_t crlDistributionPointsObjects[] = {
- { 0, "crlDistributionPoints", ASN1_SEQUENCE, ASN1_LOOP }, /* 0 */
- { 1, "DistributionPoint", ASN1_SEQUENCE, ASN1_NONE }, /* 1 */
- { 2, "distributionPoint", ASN1_CONTEXT_C_0, ASN1_OPT|ASN1_LOOP }, /* 2 */
- { 3, "fullName", ASN1_CONTEXT_C_0, ASN1_OPT|ASN1_OBJ }, /* 3 */
- { 3, "end choice", ASN1_EOC, ASN1_END }, /* 4 */
- { 3, "nameRelToCRLIssuer",ASN1_CONTEXT_C_1, ASN1_OPT|ASN1_BODY }, /* 5 */
- { 3, "end choice", ASN1_EOC, ASN1_END }, /* 6 */
- { 2, "end opt", ASN1_EOC, ASN1_END }, /* 7 */
- { 2, "reasons", ASN1_CONTEXT_C_1, ASN1_OPT|ASN1_BODY }, /* 8 */
- { 2, "end opt", ASN1_EOC, ASN1_END }, /* 9 */
- { 2, "crlIssuer", ASN1_CONTEXT_C_2, ASN1_OPT|ASN1_OBJ }, /* 10 */
- { 2, "end opt", ASN1_EOC, ASN1_END }, /* 11 */
- { 0, "end loop", ASN1_EOC, ASN1_END }, /* 12 */
- { 0, "exit", ASN1_EOC, ASN1_EXIT }
+ { 0, "crlDistributionPoints", ASN1_SEQUENCE, ASN1_LOOP }, /* 0 */
+ { 1, "DistributionPoint", ASN1_SEQUENCE, ASN1_NONE }, /* 1 */
+ { 2, "distributionPoint", ASN1_CONTEXT_C_0, ASN1_OPT|ASN1_CHOICE }, /* 2 */
+ { 3, "fullName", ASN1_CONTEXT_C_0, ASN1_OPT|ASN1_OBJ }, /* 3 */
+ { 3, "end choice", ASN1_EOC, ASN1_END|ASN1_CH }, /* 4 */
+ { 3, "nameRelToCRLIssuer",ASN1_CONTEXT_C_1, ASN1_OPT|ASN1_BODY }, /* 5 */
+ { 3, "end choice", ASN1_EOC, ASN1_END|ASN1_CH }, /* 6 */
+ { 2, "end opt/choices", ASN1_EOC, ASN1_END|ASN1_CHOICE }, /* 7 */
+ { 2, "reasons", ASN1_CONTEXT_C_1, ASN1_OPT|ASN1_BODY }, /* 8 */
+ { 2, "end opt", ASN1_EOC, ASN1_END }, /* 9 */
+ { 2, "crlIssuer", ASN1_CONTEXT_C_2, ASN1_OPT|ASN1_OBJ }, /* 10 */
+ { 2, "end opt", ASN1_EOC, ASN1_END }, /* 11 */
+ { 0, "end loop", ASN1_EOC, ASN1_END }, /* 12 */
+ { 0, "exit", ASN1_EOC, ASN1_EXIT }
};
#define CRL_DIST_POINTS 1
#define CRL_DIST_POINTS_FULLNAME 3
@@ -801,7 +844,7 @@ static void add_cdps(linked_list_t *list, linked_list_t *uris,
while (uris->remove_last(uris, (void**)&id) == SUCCESS)
{
- if (asprintf(&uri, "%Y", id) > 0)
+ if (gn_to_string(id, &uri))
{
if (issuers->get_count(issuers))
{
@@ -836,13 +879,14 @@ static void add_cdps(linked_list_t *list, linked_list_t *uris,
/**
* Extracts one or several crlDistributionPoints into a list
*/
-void x509_parse_crlDistributionPoints(chunk_t blob, int level0,
+bool x509_parse_crlDistributionPoints(chunk_t blob, int level0,
linked_list_t *list)
{
linked_list_t *uris, *issuers;
asn1_parser_t *parser;
chunk_t object;
int objectID;
+ bool success = FALSE;
uris = linked_list_create();
issuers = linked_list_create();
@@ -857,37 +901,45 @@ void x509_parse_crlDistributionPoints(chunk_t blob, int level0,
add_cdps(list, uris, issuers);
break;
case CRL_DIST_POINTS_FULLNAME:
- x509_parse_generalNames(object, parser->get_level(parser) + 1,
- TRUE, uris);
+ if (!x509_parse_generalNames(object,
+ parser->get_level(parser) + 1, TRUE, uris))
+ {
+ goto end;
+ }
break;
case CRL_DIST_POINTS_ISSUER:
- x509_parse_generalNames(object, parser->get_level(parser) + 1,
- TRUE, issuers);
+ if (!x509_parse_generalNames(object,
+ parser->get_level(parser) + 1, TRUE, issuers))
+ {
+ goto end;
+ }
break;
default:
break;
}
}
- parser->destroy(parser);
-
+ success = parser->success(parser);
add_cdps(list, uris, issuers);
- uris->destroy(uris);
- issuers->destroy(issuers);
+end:
+ parser->destroy(parser);
+ uris->destroy_offset(uris, offsetof(identification_t, destroy));
+ issuers->destroy_offset(issuers, offsetof(identification_t, destroy));
+
+ return success;
}
/**
* ASN.1 definition of nameConstraints
*/
static const asn1Object_t nameConstraintsObjects[] = {
- { 0, "nameConstraints", ASN1_SEQUENCE, ASN1_LOOP }, /* 0 */
+ { 0, "nameConstraints", ASN1_SEQUENCE, ASN1_NONE }, /* 0 */
{ 1, "permittedSubtrees", ASN1_CONTEXT_C_0, ASN1_OPT|ASN1_LOOP }, /* 1 */
{ 2, "generalSubtree", ASN1_SEQUENCE, ASN1_BODY }, /* 2 */
{ 1, "end loop", ASN1_EOC, ASN1_END }, /* 3 */
{ 1, "excludedSubtrees", ASN1_CONTEXT_C_1, ASN1_OPT|ASN1_LOOP }, /* 4 */
{ 2, "generalSubtree", ASN1_SEQUENCE, ASN1_BODY }, /* 5 */
{ 1, "end loop", ASN1_EOC, ASN1_END }, /* 6 */
- { 0, "end loop", ASN1_EOC, ASN1_END }, /* 7 */
{ 0, "exit", ASN1_EOC, ASN1_EXIT }
};
#define NAME_CONSTRAINT_PERMITTED 2
@@ -896,13 +948,14 @@ static const asn1Object_t nameConstraintsObjects[] = {
/**
* Parse permitted/excluded nameConstraints
*/
-static void parse_nameConstraints(chunk_t blob, int level0,
+static bool parse_nameConstraints(chunk_t blob, int level0,
private_x509_cert_t *this)
{
asn1_parser_t *parser;
identification_t *id;
chunk_t object;
int objectID;
+ bool success = FALSE;
parser = asn1_parser_create(nameConstraintsObjects, blob);
parser->set_top_level(parser, level0);
@@ -913,59 +966,69 @@ static void parse_nameConstraints(chunk_t blob, int level0,
{
case NAME_CONSTRAINT_PERMITTED:
id = parse_generalName(object, parser->get_level(parser) + 1);
- if (id)
+ if (!id)
{
- this->permitted_names->insert_last(this->permitted_names, id);
+ goto end;
}
+ this->permitted_names->insert_last(this->permitted_names, id);
break;
case NAME_CONSTRAINT_EXCLUDED:
id = parse_generalName(object, parser->get_level(parser) + 1);
- if (id)
+ if (!id)
{
- this->excluded_names->insert_last(this->excluded_names, id);
+ goto end;
}
+ this->excluded_names->insert_last(this->excluded_names, id);
break;
default:
break;
}
}
+ success = parser->success(parser);
+
+end:
parser->destroy(parser);
+
+ return success;
}
/**
* ASN.1 definition of a certificatePolicies extension
*/
static const asn1Object_t certificatePoliciesObject[] = {
- { 0, "certificatePolicies", ASN1_SEQUENCE, ASN1_LOOP }, /* 0 */
- { 1, "policyInformation", ASN1_SEQUENCE, ASN1_NONE }, /* 1 */
- { 2, "policyId", ASN1_OID, ASN1_BODY }, /* 2 */
- { 2, "qualifiers", ASN1_SEQUENCE, ASN1_OPT|ASN1_LOOP }, /* 3 */
- { 3, "qualifierInfo", ASN1_SEQUENCE, ASN1_NONE }, /* 4 */
- { 4, "qualifierId", ASN1_OID, ASN1_BODY }, /* 5 */
- { 4, "cPSuri", ASN1_IA5STRING, ASN1_OPT|ASN1_BODY }, /* 6 */
- { 4, "end choice", ASN1_EOC, ASN1_END }, /* 7 */
- { 4, "userNotice", ASN1_SEQUENCE, ASN1_OPT|ASN1_BODY }, /* 8 */
- { 5, "explicitText", ASN1_EOC, ASN1_RAW }, /* 9 */
- { 4, "end choice", ASN1_EOC, ASN1_END }, /* 10 */
- { 2, "end opt/loop", ASN1_EOC, ASN1_END }, /* 12 */
- { 0, "end loop", ASN1_EOC, ASN1_END }, /* 13 */
- { 0, "exit", ASN1_EOC, ASN1_EXIT }
+ { 0, "certificatePolicies", ASN1_SEQUENCE, ASN1_LOOP }, /* 0 */
+ { 1, "policyInformation", ASN1_SEQUENCE, ASN1_NONE }, /* 1 */
+ { 2, "policyId", ASN1_OID, ASN1_BODY }, /* 2 */
+ { 2, "qualifiers", ASN1_SEQUENCE, ASN1_OPT|ASN1_LOOP }, /* 3 */
+ { 3, "qualifierInfo", ASN1_SEQUENCE, ASN1_NONE }, /* 4 */
+ { 4, "qualifierId", ASN1_OID, ASN1_BODY }, /* 5 */
+ { 4, "qualifier", ASN1_EOC, ASN1_CHOICE }, /* 6 */
+ { 5, "cPSuri", ASN1_IA5STRING, ASN1_OPT|ASN1_BODY }, /* 7 */
+ { 5, "end choice", ASN1_EOC, ASN1_END|ASN1_CH }, /* 8 */
+ { 5, "userNotice", ASN1_SEQUENCE, ASN1_OPT|ASN1_BODY }, /* 9 */
+ { 6, "explicitText", ASN1_EOC, ASN1_RAW }, /* 10 */
+ { 5, "end choice", ASN1_EOC, ASN1_END|ASN1_CH }, /* 11 */
+ { 4, "end choices", ASN1_EOC, ASN1_END|ASN1_CHOICE }, /* 12 */
+ { 2, "end opt/loop", ASN1_EOC, ASN1_END }, /* 13 */
+ { 0, "end loop", ASN1_EOC, ASN1_END }, /* 14 */
+ { 0, "exit", ASN1_EOC, ASN1_EXIT }
};
-#define CERT_POLICY_ID 2
-#define CERT_POLICY_QUALIFIER_ID 5
-#define CERT_POLICY_CPS_URI 6
-#define CERT_POLICY_EXPLICIT_TEXT 9
+#define CERT_POLICY_ID 2
+#define CERT_POLICY_QUALIFIER_ID 5
+#define CERT_POLICY_CPS_URI 7
+#define CERT_POLICY_EXPLICIT_TEXT 10
/**
* Parse certificatePolicies
*/
-static void parse_certificatePolicies(chunk_t blob, int level0,
+static bool parse_certificatePolicies(chunk_t blob, int level0,
private_x509_cert_t *this)
{
x509_cert_policy_t *policy = NULL;
asn1_parser_t *parser;
chunk_t object;
int objectID, qualifier = OID_UNKNOWN;
+ bool success;
parser = asn1_parser_create(certificatePoliciesObject, blob);
parser->set_top_level(parser, level0);
@@ -998,7 +1061,10 @@ static void parse_certificatePolicies(chunk_t blob, int level0,
break;
}
}
+ success = parser->success(parser);
parser->destroy(parser);
+
+ return success;
}
/**
@@ -1019,13 +1085,14 @@ static const asn1Object_t policyMappingsObjects[] = {
/**
* Parse policyMappings
*/
-static void parse_policyMappings(chunk_t blob, int level0,
+static bool parse_policyMappings(chunk_t blob, int level0,
private_x509_cert_t *this)
{
x509_policy_mapping_t *map = NULL;
asn1_parser_t *parser;
chunk_t object;
int objectID;
+ bool success;
parser = asn1_parser_create(policyMappingsObjects, blob);
parser->set_top_level(parser, level0);
@@ -1054,7 +1121,10 @@ static void parse_policyMappings(chunk_t blob, int level0,
break;
}
}
+ success = parser->success(parser);
parser->destroy(parser);
+
+ return success;
}
/**
@@ -1076,12 +1146,13 @@ static const asn1Object_t policyConstraintsObjects[] = {
/**
* Parse policyConstraints
*/
-static void parse_policyConstraints(chunk_t blob, int level0,
+static bool parse_policyConstraints(chunk_t blob, int level0,
private_x509_cert_t *this)
{
asn1_parser_t *parser;
chunk_t object;
int objectID;
+ bool success;
parser = asn1_parser_create(policyConstraintsObjects, blob);
parser->set_top_level(parser, level0);
@@ -1100,34 +1171,41 @@ static void parse_policyConstraints(chunk_t blob, int level0,
break;
}
}
+ success = parser->success(parser);
parser->destroy(parser);
+
+ return success;
}
/**
* ASN.1 definition of ipAddrBlocks according to RFC 3779
*/
static const asn1Object_t ipAddrBlocksObjects[] = {
- { 0, "ipAddrBlocks", ASN1_SEQUENCE, ASN1_LOOP }, /* 0 */
- { 1, "ipAddressFamily", ASN1_SEQUENCE, ASN1_NONE }, /* 1 */
- { 2, "addressFamily", ASN1_OCTET_STRING, ASN1_BODY }, /* 2 */
- { 2, "inherit", ASN1_NULL, ASN1_OPT|ASN1_NONE }, /* 3 */
- { 2, "end choice", ASN1_EOC, ASN1_END }, /* 4 */
- { 2, "addressesOrRanges", ASN1_SEQUENCE, ASN1_OPT|ASN1_LOOP }, /* 5 */
- { 3, "addressPrefix", ASN1_BIT_STRING, ASN1_OPT|ASN1_BODY }, /* 6 */
- { 3, "end choice", ASN1_EOC, ASN1_END }, /* 7 */
- { 3, "addressRange", ASN1_SEQUENCE, ASN1_OPT|ASN1_NONE }, /* 8 */
- { 4, "min", ASN1_BIT_STRING, ASN1_BODY }, /* 9 */
- { 4, "max", ASN1_BIT_STRING, ASN1_BODY }, /* 10 */
- { 3, "end choice", ASN1_EOC, ASN1_END }, /* 11 */
- { 2, "end opt/loop", ASN1_EOC, ASN1_END }, /* 12 */
- { 0, "end loop", ASN1_EOC, ASN1_END }, /* 13 */
- { 0, "exit", ASN1_EOC, ASN1_EXIT }
+ { 0, "ipAddrBlocks", ASN1_SEQUENCE, ASN1_LOOP }, /* 0 */
+ { 1, "ipAddressFamily", ASN1_SEQUENCE, ASN1_NONE }, /* 1 */
+ { 2, "addressFamily", ASN1_OCTET_STRING, ASN1_BODY }, /* 2 */
+ { 2, "ipAddressChoice", ASN1_EOC, ASN1_CHOICE }, /* 3 */
+ { 3, "inherit", ASN1_NULL, ASN1_OPT }, /* 4 */
+ { 3, "end choice", ASN1_EOC, ASN1_END|ASN1_CH }, /* 5 */
+ { 3, "addressesOrRanges", ASN1_SEQUENCE, ASN1_OPT|ASN1_LOOP }, /* 6 */
+ { 4, "addressOrRange", ASN1_EOC, ASN1_CHOICE }, /* 7 */
+ { 5, "addressPrefix", ASN1_BIT_STRING, ASN1_OPT|ASN1_BODY }, /* 8 */
+ { 5, "end choice", ASN1_EOC, ASN1_END|ASN1_CH }, /* 9 */
+ { 5, "addressRange", ASN1_SEQUENCE, ASN1_OPT }, /* 10 */
+ { 6, "min", ASN1_BIT_STRING, ASN1_BODY }, /* 11 */
+ { 6, "max", ASN1_BIT_STRING, ASN1_BODY }, /* 12 */
+ { 5, "end choice", ASN1_EOC, ASN1_END|ASN1_CH }, /* 13 */
+ { 4, "end choices", ASN1_EOC, ASN1_END|ASN1_CHOICE }, /* 14 */
+ { 3, "end loop/choice", ASN1_EOC, ASN1_END|ASN1_CH }, /* 15 */
+ { 2, "end choices", ASN1_EOC, ASN1_END|ASN1_CHOICE }, /* 16 */
+ { 0, "end loop", ASN1_EOC, ASN1_END }, /* 17 */
+ { 0, "exit", ASN1_EOC, ASN1_EXIT }
};
#define IP_ADDR_BLOCKS_FAMILY 2
-#define IP_ADDR_BLOCKS_INHERIT 3
-#define IP_ADDR_BLOCKS_PREFIX 6
-#define IP_ADDR_BLOCKS_MIN 9
-#define IP_ADDR_BLOCKS_MAX 10
+#define IP_ADDR_BLOCKS_INHERIT 4
+#define IP_ADDR_BLOCKS_PREFIX 8
+#define IP_ADDR_BLOCKS_MIN 11
+#define IP_ADDR_BLOCKS_MAX 12
static bool check_address_object(ts_type_t ts_type, chunk_t object)
{
@@ -1171,7 +1249,7 @@ static bool check_address_object(ts_type_t ts_type, chunk_t object)
return TRUE;
}
-static void parse_ipAddrBlocks(chunk_t blob, int level0,
+static bool parse_ipAddrBlocks(chunk_t blob, int level0,
private_x509_cert_t *this)
{
asn1_parser_t *parser;
@@ -1179,6 +1257,7 @@ static void parse_ipAddrBlocks(chunk_t blob, int level0,
ts_type_t ts_type = 0;
traffic_selector_t *ts;
int objectID;
+ bool success = FALSE;
parser = asn1_parser_create(ipAddrBlocksObjects, blob);
parser->set_top_level(parser, level0);
@@ -1240,10 +1319,13 @@ static void parse_ipAddrBlocks(chunk_t blob, int level0,
break;
}
}
+ success = parser->success(parser);
this->flags |= X509_IP_ADDR_BLOCKS;
end:
parser->destroy(parser);
+
+ return success;
}
/**
@@ -1387,43 +1469,74 @@ static bool parse_certificate(private_x509_cert_t *this)
this->subjectKeyIdentifier = object;
break;
case OID_SUBJECT_ALT_NAME:
- x509_parse_generalNames(object, level, FALSE,
- this->subjectAltNames);
+ if (!x509_parse_generalNames(object, level, FALSE,
+ this->subjectAltNames))
+ {
+ goto end;
+ }
break;
case OID_BASIC_CONSTRAINTS:
- parse_basicConstraints(object, level, this);
+ if (!parse_basicConstraints(object, level, this))
+ {
+ goto end;
+ }
break;
case OID_CRL_DISTRIBUTION_POINTS:
- x509_parse_crlDistributionPoints(object, level,
- this->crl_uris);
+ if (!x509_parse_crlDistributionPoints(object, level,
+ this->crl_uris))
+ {
+ goto end;
+ }
break;
case OID_AUTHORITY_KEY_ID:
- this->authKeyIdentifier = x509_parse_authorityKeyIdentifier(object,
- level, &this->authKeySerialNumber);
+ chunk_free(&this->authKeyIdentifier);
+ this->authKeyIdentifier = x509_parse_authorityKeyIdentifier(
+ object, level, &this->authKeySerialNumber);
break;
case OID_AUTHORITY_INFO_ACCESS:
- parse_authorityInfoAccess(object, level, this);
+ if (!parse_authorityInfoAccess(object, level, this))
+ {
+ goto end;
+ }
break;
case OID_KEY_USAGE:
parse_keyUsage(object, this);
break;
case OID_EXTENDED_KEY_USAGE:
- parse_extendedKeyUsage(object, level, this);
+ if (!parse_extendedKeyUsage(object, level, this))
+ {
+ goto end;
+ }
break;
case OID_IP_ADDR_BLOCKS:
- parse_ipAddrBlocks(object, level, this);
+ if (!parse_ipAddrBlocks(object, level, this))
+ {
+ goto end;
+ }
break;
case OID_NAME_CONSTRAINTS:
- parse_nameConstraints(object, level, this);
+ if (!parse_nameConstraints(object, level, this))
+ {
+ goto end;
+ }
break;
case OID_CERTIFICATE_POLICIES:
- parse_certificatePolicies(object, level, this);
+ if (!parse_certificatePolicies(object, level, this))
+ {
+ goto end;
+ }
break;
case OID_POLICY_MAPPINGS:
- parse_policyMappings(object, level, this);
+ if (!parse_policyMappings(object, level, this))
+ {
+ goto end;
+ }
break;
case OID_POLICY_CONSTRAINTS:
- parse_policyConstraints(object, level, this);
+ if (!parse_policyConstraints(object, level, this))
+ {
+ goto end;
+ }
break;
case OID_INHIBIT_ANY_POLICY:
if (!asn1_parse_simple_object(&object, ASN1_INTEGER,
diff --git a/src/libstrongswan/plugins/x509/x509_crl.c b/src/libstrongswan/plugins/x509/x509_crl.c
index 4d7e7bd10..d8913ad73 100644
--- a/src/libstrongswan/plugins/x509/x509_crl.c
+++ b/src/libstrongswan/plugins/x509/x509_crl.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2008-2009 Martin Willi
- * Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2017 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -149,7 +150,7 @@ extern chunk_t x509_parse_authorityKeyIdentifier(chunk_t blob, int level0,
/**
* from x509_cert
*/
-extern void x509_parse_crlDistributionPoints(chunk_t blob, int level0,
+extern bool x509_parse_crlDistributionPoints(chunk_t blob, int level0,
linked_list_t *list);
/**
@@ -309,8 +310,11 @@ static bool parse(private_x509_crl_t *this)
this->crlNumber = object;
break;
case OID_FRESHEST_CRL:
- x509_parse_crlDistributionPoints(object, level,
- this->crl_uris);
+ if (!x509_parse_crlDistributionPoints(object, level,
+ this->crl_uris))
+ {
+ goto end;
+ }
break;
case OID_DELTA_CRL_INDICATOR:
if (!asn1_parse_simple_object(&object, ASN1_INTEGER,
@@ -360,25 +364,33 @@ end:
return success;
}
-/**
- * enumerator filter callback for create_enumerator
- */
-static bool filter(void *data, revoked_t **revoked, chunk_t *serial, void *p2,
- time_t *date, void *p3, crl_reason_t *reason)
+CALLBACK(filter, bool,
+ void *data, enumerator_t *orig, va_list args)
{
- if (serial)
- {
- *serial = (*revoked)->serial;
- }
- if (date)
- {
- *date = (*revoked)->date;
- }
- if (reason)
+ revoked_t *revoked;
+ crl_reason_t *reason;
+ chunk_t *serial;
+ time_t *date;
+
+ VA_ARGS_VGET(args, serial, date, reason);
+
+ if (orig->enumerate(orig, &revoked))
{
- *reason = (*revoked)->reason;
+ if (serial)
+ {
+ *serial = revoked->serial;
+ }
+ if (date)
+ {
+ *date = revoked->date;
+ }
+ if (reason)
+ {
+ *reason = revoked->reason;
+ }
+ return TRUE;
}
- return TRUE;
+ return FALSE;
}
METHOD(crl_t, get_serial, chunk_t,
@@ -418,7 +430,7 @@ METHOD(crl_t, create_enumerator, enumerator_t*,
{
return enumerator_create_filter(
this->revoked->create_enumerator(this->revoked),
- (void*)filter, NULL, NULL);
+ filter, NULL, NULL);
}
METHOD(certificate_t, get_type, certificate_type_t,
diff --git a/src/libstrongswan/plugins/x509/x509_ocsp_response.c b/src/libstrongswan/plugins/x509/x509_ocsp_response.c
index b46af30fe..140e9bfa9 100644
--- a/src/libstrongswan/plugins/x509/x509_ocsp_response.c
+++ b/src/libstrongswan/plugins/x509/x509_ocsp_response.c
@@ -228,32 +228,38 @@ METHOD(ocsp_response_t, create_cert_enumerator, enumerator_t*,
return this->certs->create_enumerator(this->certs);
}
-/**
- * enumerator filter callback for create_response_enumerator
- */
-static bool filter(void *data, single_response_t **response,
- chunk_t *serialNumber,
- void *p2, cert_validation_t *status,
- void *p3, time_t *revocationTime,
- void *p4, crl_reason_t *revocationReason)
+CALLBACK(filter, bool,
+ void *data, enumerator_t *orig, va_list args)
{
- if (serialNumber)
- {
- *serialNumber = (*response)->serialNumber;
- }
- if (status)
- {
- *status = (*response)->status;
- }
- if (revocationTime)
- {
- *revocationTime = (*response)->revocationTime;
- }
- if (revocationReason)
+ single_response_t *response;
+ cert_validation_t *status;
+ crl_reason_t *revocationReason;
+ chunk_t *serialNumber;
+ time_t *revocationTime;
+
+ VA_ARGS_VGET(args, serialNumber, status, revocationTime, revocationReason);
+
+ if (orig->enumerate(orig, &response))
{
- *revocationReason = (*response)->revocationReason;
+ if (serialNumber)
+ {
+ *serialNumber = response->serialNumber;
+ }
+ if (status)
+ {
+ *status = response->status;
+ }
+ if (revocationTime)
+ {
+ *revocationTime = response->revocationTime;
+ }
+ if (revocationReason)
+ {
+ *revocationReason = response->revocationReason;
+ }
+ return TRUE;
}
- return TRUE;
+ return FALSE;
}
METHOD(ocsp_response_t, create_response_enumerator, enumerator_t*,
@@ -261,7 +267,7 @@ METHOD(ocsp_response_t, create_response_enumerator, enumerator_t*,
{
return enumerator_create_filter(
this->responses->create_enumerator(this->responses),
- (void*)filter, NULL, NULL);
+ filter, NULL, NULL);
}
/**
diff --git a/src/libstrongswan/plugins/x509/x509_pkcs10.c b/src/libstrongswan/plugins/x509/x509_pkcs10.c
index 20561f7e2..e39e24bff 100644
--- a/src/libstrongswan/plugins/x509/x509_pkcs10.c
+++ b/src/libstrongswan/plugins/x509/x509_pkcs10.c
@@ -1,7 +1,6 @@
/*
* Copyright (C) 2005 Jan Hutter, Martin Willi
- * Copyright (C) 2009 Andreas Steffen
- *
+ * Copyright (C) 2009-2017 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -101,7 +100,8 @@ struct private_x509_pkcs10_t {
/**
* Imported from x509_cert.c
*/
-extern void x509_parse_generalNames(chunk_t blob, int level0, bool implicit, linked_list_t *list);
+extern bool x509_parse_generalNames(chunk_t blob, int level0, bool implicit,
+ linked_list_t *list);
extern chunk_t x509_build_subjectAltNames(linked_list_t *list);
METHOD(certificate_t, get_type, certificate_type_t,
@@ -290,8 +290,11 @@ static bool parse_extension_request(private_x509_pkcs10_t *this, chunk_t blob, i
switch (extn_oid)
{
case OID_SUBJECT_ALT_NAME:
- x509_parse_generalNames(object, level, FALSE,
- this->subjectAltNames);
+ if (!x509_parse_generalNames(object, level, FALSE,
+ this->subjectAltNames))
+ {
+ goto end;
+ }
break;
default:
break;
@@ -303,7 +306,10 @@ static bool parse_extension_request(private_x509_pkcs10_t *this, chunk_t blob, i
}
}
success = parser->success(parser);
+
+end:
parser->destroy(parser);
+
return success;
}
diff --git a/src/libstrongswan/plugins/xcbc/Makefile.in b/src/libstrongswan/plugins/xcbc/Makefile.in
index 78f9268c2..a23130851 100644
--- a/src/libstrongswan/plugins/xcbc/Makefile.in
+++ b/src/libstrongswan/plugins/xcbc/Makefile.in
@@ -355,6 +355,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -377,6 +378,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/processing/processor.c b/src/libstrongswan/processing/processor.c
index 27e5ab5f6..bd8d534a5 100644
--- a/src/libstrongswan/processing/processor.c
+++ b/src/libstrongswan/processing/processor.c
@@ -429,7 +429,15 @@ METHOD(processor_t, execute_job, void,
METHOD(processor_t, set_threads, void,
private_processor_t *this, u_int count)
{
+ int i;
+
this->mutex->lock(this->mutex);
+ for (i = 0; i < JOB_PRIO_MAX; i++)
+ {
+ this->prio_threads[i] = lib->settings->get_int(lib->settings,
+ "%s.processor.priority_threads.%N", 0, lib->ns,
+ job_priority_names, i);
+ }
if (count > this->total_threads)
{ /* increase thread count */
worker_thread_t *worker;
@@ -551,13 +559,10 @@ processor_t *processor_create()
.job_added = condvar_create(CONDVAR_TYPE_DEFAULT),
.thread_terminated = condvar_create(CONDVAR_TYPE_DEFAULT),
);
+
for (i = 0; i < JOB_PRIO_MAX; i++)
{
this->jobs[i] = linked_list_create();
- this->prio_threads[i] = lib->settings->get_int(lib->settings,
- "%s.processor.priority_threads.%N", 0, lib->ns,
- job_priority_names, i);
}
-
return &this->public;
}
diff --git a/src/libstrongswan/settings/settings.c b/src/libstrongswan/settings/settings.c
index b00e8190c..2a92d523b 100644
--- a/src/libstrongswan/settings/settings.c
+++ b/src/libstrongswan/settings/settings.c
@@ -744,10 +744,8 @@ typedef struct {
hashtable_t *seen;
} enumerator_data_t;
-/**
- * Destroy enumerator data
- */
-static void enumerator_destroy(enumerator_data_t *this)
+CALLBACK(enumerator_destroy, void,
+ enumerator_data_t *this)
{
this->settings->lock->unlock(this->settings->lock);
this->seen->destroy(this->seen);
@@ -755,18 +753,25 @@ static void enumerator_destroy(enumerator_data_t *this)
free(this);
}
-/**
- * Enumerate section names, not sections
- */
-static bool section_filter(hashtable_t *seen, section_t **in, char **out)
+CALLBACK(section_filter, bool,
+ hashtable_t *seen, enumerator_t *orig, va_list args)
{
- *out = (*in)->name;
- if (seen->get(seen, *out))
+ section_t *section;
+ char **out;
+
+ VA_ARGS_VGET(args, out);
+
+ while (orig->enumerate(orig, &section))
{
- return FALSE;
+ if (seen->get(seen, section->name))
+ {
+ continue;
+ }
+ *out = section->name;
+ seen->put(seen, section->name, section->name);
+ return TRUE;
}
- seen->put(seen, *out, *out);
- return TRUE;
+ return FALSE;
}
/**
@@ -776,8 +781,8 @@ static enumerator_t *section_enumerator(section_t *section,
enumerator_data_t *data)
{
return enumerator_create_filter(
- array_create_enumerator(section->sections_order),
- (void*)section_filter, data->seen, NULL);
+ array_create_enumerator(section->sections_order),
+ section_filter, data->seen, NULL);
}
METHOD(settings_t, create_section_enumerator, enumerator_t*,
@@ -803,23 +808,29 @@ METHOD(settings_t, create_section_enumerator, enumerator_t*,
.seen = hashtable_create(hashtable_hash_str, hashtable_equals_str, 8),
);
return enumerator_create_nested(array_create_enumerator(sections),
- (void*)section_enumerator, data, (void*)enumerator_destroy);
+ (void*)section_enumerator, data, enumerator_destroy);
}
-/**
- * Enumerate key and values, not kv_t entries
- */
-static bool kv_filter(hashtable_t *seen, kv_t **in, char **key,
- void *none, char **value)
+CALLBACK(kv_filter, bool,
+ hashtable_t *seen, enumerator_t *orig, va_list args)
{
- *key = (*in)->key;
- if (seen->get(seen, *key) || !(*in)->value)
+ kv_t *kv;
+ char **key, **value;
+
+ VA_ARGS_VGET(args, key, value);
+
+ while (orig->enumerate(orig, &kv))
{
- return FALSE;
+ if (seen->get(seen, kv->key) || !kv->value)
+ {
+ continue;
+ }
+ *key = kv->key;
+ *value = kv->value;
+ seen->put(seen, kv->key, kv->key);
+ return TRUE;
}
- *value = (*in)->value;
- seen->put(seen, *key, *key);
- return TRUE;
+ return FALSE;
}
/**
@@ -828,7 +839,7 @@ static bool kv_filter(hashtable_t *seen, kv_t **in, char **key,
static enumerator_t *kv_enumerator(section_t *section, enumerator_data_t *data)
{
return enumerator_create_filter(array_create_enumerator(section->kv_order),
- (void*)kv_filter, data->seen, NULL);
+ kv_filter, data->seen, NULL);
}
METHOD(settings_t, create_key_value_enumerator, enumerator_t*,
diff --git a/src/libstrongswan/tests/Makefile.in b/src/libstrongswan/tests/Makefile.in
index f4c607ca4..279e179ea 100644
--- a/src/libstrongswan/tests/Makefile.in
+++ b/src/libstrongswan/tests/Makefile.in
@@ -396,6 +396,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -418,6 +419,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/tests/suites/test_asn1_parser.c b/src/libstrongswan/tests/suites/test_asn1_parser.c
index 973562bff..ebbe7ddaf 100644
--- a/src/libstrongswan/tests/suites/test_asn1_parser.c
+++ b/src/libstrongswan/tests/suites/test_asn1_parser.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Andreas Steffen
+ * Copyright (C) 2014-2017 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -250,6 +250,7 @@ START_TEST(test_asn1_parser_option)
i3 = *object.ptr;
break;
default:
+
break;
}
}
@@ -264,6 +265,105 @@ START_TEST(test_asn1_parser_option)
}
END_TEST
+/*******************************************************************************
+ * choice
+ */
+
+typedef struct {
+ int i1, i2, i3, i4;
+ chunk_t blob;
+} choice_test_t;
+
+static const asn1Object_t choiceObjects[] = {
+ { 0, "choiceObject", ASN1_EOC, ASN1_CHOICE }, /* 0 */
+ { 1, "choiceA", ASN1_CONTEXT_C_0, ASN1_OPT|ASN1_CHOICE }, /* 1 */
+ { 2, "choice1", ASN1_OCTET_STRING, ASN1_OPT|ASN1_BODY }, /* 2 */
+ { 2, "end choice1", ASN1_EOC, ASN1_END|ASN1_CH }, /* 3 */
+ { 2, "choice2", ASN1_INTEGER, ASN1_OPT|ASN1_BODY }, /* 4 */
+ { 2, "end choice2", ASN1_EOC, ASN1_END|ASN1_CH }, /* 5 */
+ { 1, "end choiceA", ASN1_EOC, ASN1_END|ASN1_CHOICE|
+ ASN1_CH }, /* 6 */
+ { 1, "choiceB", ASN1_SEQUENCE, ASN1_OPT|ASN1_LOOP }, /* 7 */
+ { 2, "choiceObject", ASN1_EOC, ASN1_CHOICE }, /* 8 */
+ { 3, "choice3", ASN1_INTEGER, ASN1_OPT|ASN1_BODY }, /* 9 */
+ { 3, "end choice3", ASN1_EOC, ASN1_END|ASN1_CH }, /* 10 */
+ { 3, "choice4", ASN1_OCTET_STRING, ASN1_OPT|ASN1_BODY }, /* 11 */
+ { 3, "end choice4", ASN1_EOC, ASN1_END|ASN1_CH }, /* 12 */
+ { 2, "end choices", ASN1_EOC, ASN1_END|ASN1_CHOICE }, /* 13 */
+ { 1, "end loop/choice", ASN1_EOC, ASN1_END|ASN1_CH }, /* 14 */
+ { 0, "end choices", ASN1_EOC, ASN1_END|ASN1_CHOICE }, /* 15 */
+ { 0, "exit", ASN1_EOC, ASN1_EXIT }
+};
+
+choice_test_t choice_tests[] = {
+ { 0, 0, 0, 0, { NULL, 0 } },
+ { 0, 0, 0, 0, chunk_from_chars(0xA0, 0x00) },
+ { 1, 0, 0, 0, chunk_from_chars(0xA0, 0x03, 0x04, 0x01, 0x01) },
+ { 1, 0, 0, 0, chunk_from_chars(0xA0, 0x06, 0x04, 0x01, 0x01,
+ 0x02, 0x01, 0x02) },
+ { 0, 2, 0, 0, chunk_from_chars(0xA0, 0x03, 0x02, 0x01, 0x02) },
+ { 0, 2, 0, 0, chunk_from_chars(0xA0, 0x03, 0x02, 0x01, 0x02,
+ 0x30, 0x03, 0x02, 0x01, 0x03) },
+ { 0, 0, 0, 0, chunk_from_chars(0xA0, 0x04, 0x03, 0x02, 0x00, 0x04) },
+ { 0, 0, 3, 0, chunk_from_chars(0x30, 0x03, 0x02, 0x01, 0x03) },
+ { 0, 0, 0, 4, chunk_from_chars(0x30, 0x03, 0x04, 0x01, 0x04) },
+ { 0, 0, 3, 4, chunk_from_chars(0x30, 0x06, 0x04, 0x01, 0x04,
+ 0x02, 0x01, 0x03) },
+ { 0, 0, 3, 4, chunk_from_chars(0x30, 0x06, 0x02, 0x01, 0x03,
+ 0x04, 0x01, 0x04) },
+ { 0, 0, 6, 0, chunk_from_chars(0x30, 0x06, 0x02, 0x01, 0x03,
+ 0x02, 0x01, 0x03) },
+ { 0, 0, 0, 8, chunk_from_chars(0x30, 0x06, 0x04, 0x01, 0x04,
+ 0x04, 0x01, 0x04) },
+ { 0, 0, 0, 0, chunk_from_chars(0x30, 0x04, 0x03, 0x02, 0x00, 0x04) },
+ { 0, 0, 0, 0, chunk_from_chars(0x03, 0x02, 0x00, 0x04) }
+};
+
+START_TEST(test_asn1_parser_choice)
+{
+ asn1_parser_t *parser;
+ chunk_t object;
+ int objectID, i1 = 0, i2 = 0, i3 = 0, i4 = 0;
+ bool success;
+
+ parser = asn1_parser_create(choiceObjects, choice_tests[_i].blob);
+ while (parser->iterate(parser, &objectID, &object))
+ {
+ switch (objectID)
+ {
+ case 2:
+ i1 += *object.ptr;
+ break;
+ case 4:
+ i2 += *object.ptr;
+ break;
+ case 9:
+ i3 += *object.ptr;
+ break;
+ case 11:
+ i4 += *object.ptr;
+ break;
+ default:
+
+ break;
+ }
+ }
+ success = parser->success(parser);
+ parser->destroy(parser);
+
+ ck_assert(success == (choice_tests[_i].i1 ||
+ choice_tests[_i].i2 ||
+ choice_tests[_i].i3 ||
+ choice_tests[_i].i4 ));
+
+ ck_assert(i1 == choice_tests[_i].i1 &&
+ i2 == choice_tests[_i].i2 &&
+ i3 == choice_tests[_i].i3 &&
+ i4 == choice_tests[_i].i4 );
+}
+END_TEST
+
+
Suite *asn1_parser_suite_create()
{
Suite *s;
@@ -287,5 +387,9 @@ Suite *asn1_parser_suite_create()
tcase_add_loop_test(tc, test_asn1_parser_option, 0, countof(option_tests));
suite_add_tcase(s, tc);
+ tc = tcase_create("choice");
+ tcase_add_loop_test(tc, test_asn1_parser_choice, 0, countof(choice_tests));
+ suite_add_tcase(s, tc);
+
return s;
}
diff --git a/src/libstrongswan/tests/suites/test_enumerator.c b/src/libstrongswan/tests/suites/test_enumerator.c
index 9bd6d24f2..b781ae9fd 100644
--- a/src/libstrongswan/tests/suites/test_enumerator.c
+++ b/src/libstrongswan/tests/suites/test_enumerator.c
@@ -104,25 +104,45 @@ static void destroy_data(void *data)
* filtered test
*/
-static bool filter(int *data, int **v, int *vo, int **w, int *wo,
- int **x, int *xo, int **y, int *yo, int **z, int *zo)
+CALLBACK(filter, bool,
+ int *data, enumerator_t *orig, va_list args)
{
- int val = **v;
+ int *item, *vo, *wo, *xo, *yo, *zo;
- *vo = val++;
- *wo = val++;
- *xo = val++;
- *yo = val++;
- *zo = val++;
- fail_if(data != (void*)101, "data does not match '101' in filter function");
- return TRUE;
+ VA_ARGS_VGET(args, vo, wo, xo, yo, zo);
+
+ if (orig->enumerate(orig, &item))
+ {
+ int val = *item;
+ *vo = val++;
+ *wo = val++;
+ *xo = val++;
+ *yo = val++;
+ *zo = val++;
+ fail_if(data != (void*)101, "data does not match '101' in filter function");
+ return TRUE;
+ }
+ return FALSE;
}
-static bool filter_odd(void *data, int **item, int *out)
+CALLBACK(filter_odd, bool,
+ void *data, enumerator_t *orig, va_list args)
{
+ int *item, *out;
+
+ VA_ARGS_VGET(args, out);
+
fail_if(data != (void*)101, "data does not match '101' in filter function");
- *out = **item;
- return **item % 2 == 0;
+
+ while (orig->enumerate(orig, &item))
+ {
+ if (*item % 2 == 0)
+ {
+ *out = *item;
+ return TRUE;
+ }
+ }
+ return FALSE;
}
START_TEST(test_filtered)
@@ -136,7 +156,7 @@ START_TEST(test_filtered)
round = 1;
enumerator = enumerator_create_filter(list->create_enumerator(list),
- (void*)filter, (void*)101, destroy_data);
+ filter, (void*)101, destroy_data);
while (enumerator->enumerate(enumerator, &v, &w, &x, &y, &z))
{
ck_assert_int_eq(v, round);
@@ -166,7 +186,7 @@ START_TEST(test_filtered_filter)
/* should also work without destructor, so set this manually */
destroy_data_called = 1;
enumerator = enumerator_create_filter(list->create_enumerator(list),
- (void*)filter_odd, (void*)101, NULL);
+ filter_odd, (void*)101, NULL);
while (enumerator->enumerate(enumerator, &x))
{
ck_assert(x % 2 == 0);
diff --git a/src/libstrongswan/tests/suites/test_linked_list.c b/src/libstrongswan/tests/suites/test_linked_list.c
index 7a161817c..aa1e0429f 100644
--- a/src/libstrongswan/tests/suites/test_linked_list.c
+++ b/src/libstrongswan/tests/suites/test_linked_list.c
@@ -183,26 +183,48 @@ END_TEST
* find
*/
-static bool match_a_b(void *item, void *a, void *b)
+CALLBACK(find_a_b, bool,
+ void *item, va_list args)
{
+ void *a, *b;
+
+ VA_ARGS_VGET(args, a, b);
ck_assert(a == (void*)1);
ck_assert(b == (void*)2);
return item == a || item == b;
}
+CALLBACK(find_a, bool,
+ void *item, va_list args)
+{
+ void *a;
+
+ VA_ARGS_VGET(args, a);
+ return match_a(item, a);
+}
+
+CALLBACK(find_b, bool,
+ void *item, va_list args)
+{
+ void *b;
+
+ VA_ARGS_VGET(args, b);
+ return match_b(item, b);
+}
+
START_TEST(test_find)
{
void *a = (void*)1, *b = (void*)2;
- ck_assert(list->find_first(list, NULL, &a) == NOT_FOUND);
+ ck_assert(!list->find_first(list, NULL, &a));
list->insert_last(list, a);
- ck_assert(list->find_first(list, NULL, &a) == SUCCESS);
- ck_assert(list->find_first(list, NULL, &b) == NOT_FOUND);
+ ck_assert(list->find_first(list, NULL, &a));
+ ck_assert(!list->find_first(list, NULL, &b));
list->insert_last(list, b);
- ck_assert(list->find_first(list, NULL, &a) == SUCCESS);
- ck_assert(list->find_first(list, NULL, &b) == SUCCESS);
+ ck_assert(list->find_first(list, NULL, &a));
+ ck_assert(list->find_first(list, NULL, &b));
- ck_assert(list->find_first(list, NULL, NULL) == NOT_FOUND);
+ ck_assert(!list->find_first(list, NULL, NULL));
}
END_TEST
@@ -210,29 +232,57 @@ START_TEST(test_find_callback)
{
void *a = (void*)1, *b = (void*)2, *x = NULL;
- ck_assert(list->find_first(list, (linked_list_match_t)match_a_b, &x, a, b) == NOT_FOUND);
+ ck_assert(!list->find_first(list, find_a_b, &x, a, b));
list->insert_last(list, a);
- ck_assert(list->find_first(list, (linked_list_match_t)match_a, NULL, a) == SUCCESS);
+ ck_assert(list->find_first(list, find_a, NULL, a));
x = NULL;
- ck_assert(list->find_first(list, (linked_list_match_t)match_a, &x, a) == SUCCESS);
+ ck_assert(list->find_first(list, find_a, &x, a));
ck_assert(a == x);
- ck_assert(list->find_first(list, (linked_list_match_t)match_b, &x, b) == NOT_FOUND);
+ ck_assert(!list->find_first(list, find_b, &x, b));
ck_assert(a == x);
x = NULL;
- ck_assert(list->find_first(list, (linked_list_match_t)match_a_b, &x, a, b) == SUCCESS);
+ ck_assert(list->find_first(list, find_a_b, &x, a, b));
ck_assert(a == x);
list->insert_last(list, b);
- ck_assert(list->find_first(list, (linked_list_match_t)match_a, &x, a) == SUCCESS);
+ ck_assert(list->find_first(list, find_a, &x, a));
ck_assert(a == x);
- ck_assert(list->find_first(list, (linked_list_match_t)match_b, &x, b) == SUCCESS);
+ ck_assert(list->find_first(list, find_b, &x, b));
ck_assert(b == x);
x = NULL;
- ck_assert(list->find_first(list, (linked_list_match_t)match_a_b, &x, a, b) == SUCCESS);
+ ck_assert(list->find_first(list, find_a_b, &x, a, b));
ck_assert(a == x);
}
END_TEST
+CALLBACK(find_args, bool,
+ void *item, va_list args)
+{
+ uint64_t d, e;
+ level_t c;
+ int *a, b;
+
+ VA_ARGS_VGET(args, a, b, c, d, e);
+ ck_assert_int_eq(*a, 1);
+ ck_assert_int_eq(b, 2);
+ ck_assert_int_eq(c, LEVEL_PRIVATE);
+ ck_assert_int_eq(d, UINT64_MAX);
+ ck_assert_int_eq(e, UINT64_MAX-1);
+ return item == a;
+}
+
+START_TEST(test_find_callback_args)
+{
+ int a = 1, b = 2, *x;
+ uint64_t d = UINT64_MAX;
+
+ list->insert_last(list, &a);
+ ck_assert(list->find_first(list, find_args, (void**)&x, &a, b,
+ LEVEL_PRIVATE, d, UINT64_MAX-1));
+ ck_assert_int_eq(a, *x);
+}
+END_TEST
+
/*******************************************************************************
* invoke
*/
@@ -241,11 +291,16 @@ typedef struct invoke_t invoke_t;
struct invoke_t {
int val;
- void (*invoke)(invoke_t *item, void *a, void *b, void *c, void *d, int *sum);
+ void (*invoke)(invoke_t *item);
};
-static void invoke(intptr_t item, void *a, void *b, void *c, void *d, int *sum)
+CALLBACK(invoke, void,
+ intptr_t item, va_list args)
{
+ void *a, *b, *c, *d;
+ int *sum;
+
+ VA_ARGS_VGET(args, a, b, c, d, sum);
ck_assert_int_eq((uintptr_t)a, 1);
ck_assert_int_eq((uintptr_t)b, 2);
ck_assert_int_eq((uintptr_t)c, 3);
@@ -253,9 +308,9 @@ static void invoke(intptr_t item, void *a, void *b, void *c, void *d, int *sum)
*sum += item;
}
-static void invoke_offset(invoke_t *item, void *a, void *b, void *c, void *d, int *sum)
+static void invoke_offset(invoke_t *item)
{
- invoke(item->val, a, b, c, d, sum);
+ item->val++;
}
START_TEST(test_invoke_function)
@@ -267,8 +322,7 @@ START_TEST(test_invoke_function)
list->insert_last(list, (void*)3);
list->insert_last(list, (void*)4);
list->insert_last(list, (void*)5);
- list->invoke_function(list, (linked_list_invoke_t)invoke,
- (uintptr_t)1, (uintptr_t)2,
+ list->invoke_function(list, invoke, (uintptr_t)1, (uintptr_t)2,
(uintptr_t)3, (uintptr_t)4, &sum);
ck_assert_int_eq(sum, 15);
}
@@ -282,17 +336,19 @@ START_TEST(test_invoke_offset)
{ .val = 3, .invoke = invoke_offset, },
{ .val = 4, .invoke = invoke_offset, },
{ .val = 5, .invoke = invoke_offset, },
- };
- int i, sum = 0;
+ }, *item;
+ int i;
for (i = 0; i < countof(items); i++)
{
list->insert_last(list, &items[i]);
}
- list->invoke_offset(list, offsetof(invoke_t, invoke),
- (uintptr_t)1, (uintptr_t)2,
- (uintptr_t)3, (uintptr_t)4, &sum);
- ck_assert_int_eq(sum, 15);
+ list->invoke_offset(list, offsetof(invoke_t, invoke));
+ i = 2;
+ while (list->remove_first(list, (void**)&item) == SUCCESS)
+ {
+ ck_assert_int_eq(item->val, i++);
+ }
}
END_TEST
@@ -458,6 +514,7 @@ Suite *linked_list_suite_create()
tcase_add_checked_fixture(tc, setup_list, teardown_list);
tcase_add_test(tc, test_find);
tcase_add_test(tc, test_find_callback);
+ tcase_add_test(tc, test_find_callback_args);
suite_add_tcase(s, tc);
tc = tcase_create("invoke");
diff --git a/src/libstrongswan/tests/test_suite.h b/src/libstrongswan/tests/test_suite.h
index 66c68465a..97c1b42c1 100644
--- a/src/libstrongswan/tests/test_suite.h
+++ b/src/libstrongswan/tests/test_suite.h
@@ -298,7 +298,7 @@ void test_fail_if_worker_failed();
chunk_t _a = (chunk_t)a; \
chunk_t _b = (chunk_t)b; \
test_fail_if_worker_failed(); \
- if (_a.len != _b.len || !memeq(a.ptr, b.ptr, a.len)) \
+ if (_a.len != _b.len || !memeq(_a.ptr, _b.ptr, _a.len)) \
{ \
test_fail_msg(__FILE__, __LINE__, \
#a " != " #b " (\"%#B\" != \"%#B\")", &_a, &_b); \
diff --git a/src/libstrongswan/utils/backtrace.c b/src/libstrongswan/utils/backtrace.c
index 6dd68d60e..18b19166e 100644
--- a/src/libstrongswan/utils/backtrace.c
+++ b/src/libstrongswan/utils/backtrace.c
@@ -668,8 +668,12 @@ typedef struct {
} frame_enumerator_t;
METHOD(enumerator_t, frame_enumerate, bool,
- frame_enumerator_t *this, void **addr)
+ frame_enumerator_t *this, va_list args)
{
+ void **addr;
+
+ VA_ARGS_VGET(args, addr);
+
if (this->i < this->bt->frame_count)
{
*addr = this->bt->frames[this->i++];
@@ -685,7 +689,8 @@ METHOD(backtrace_t, create_frame_enumerator, enumerator_t*,
INIT(enumerator,
.public = {
- .enumerate = (void*)_frame_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _frame_enumerate,
.destroy = (void*)free,
},
.bt = this,
diff --git a/src/libstrongswan/utils/chunk.c b/src/libstrongswan/utils/chunk.c
index 0c50ab788..8f4b7efff 100644
--- a/src/libstrongswan/utils/chunk.c
+++ b/src/libstrongswan/utils/chunk.c
@@ -643,7 +643,7 @@ chunk_t chunk_from_base64(chunk_t base64, char *buf)
outlen += 3;
for (j = 0; j < 4; j++)
{
- if (*pos == '=')
+ if (*pos == '=' && outlen > 0)
{
outlen--;
}
diff --git a/src/libstrongswan/utils/identification.c b/src/libstrongswan/utils/identification.c
index 384bd6c92..1a4769063 100644
--- a/src/libstrongswan/utils/identification.c
+++ b/src/libstrongswan/utils/identification.c
@@ -136,9 +136,12 @@ typedef struct {
} rdn_enumerator_t;
METHOD(enumerator_t, rdn_enumerate, bool,
- rdn_enumerator_t *this, chunk_t *oid, u_char *type, chunk_t *data)
+ rdn_enumerator_t *this, va_list args)
{
- chunk_t rdn;
+ chunk_t rdn, *oid, *data;
+ u_char *type;
+
+ VA_ARGS_VGET(args, oid, type, data);
/* a DN contains one or more SET, each containing one or more SEQUENCES,
* each containing a OID/value RDN */
@@ -173,7 +176,8 @@ static enumerator_t* create_rdn_enumerator(chunk_t dn)
INIT(e,
.public = {
- .enumerate = (void*)_rdn_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _rdn_enumerate,
.destroy = (void*)free,
},
);
@@ -199,10 +203,11 @@ typedef struct {
} rdn_part_enumerator_t;
METHOD(enumerator_t, rdn_part_enumerate, bool,
- rdn_part_enumerator_t *this, id_part_t *type, chunk_t *data)
+ rdn_part_enumerator_t *this, va_list args)
{
int i, known_oid, strtype;
- chunk_t oid, inner_data;
+ chunk_t oid, inner_data, *data;
+ id_part_t *type;
static const struct {
int oid;
id_part_t type;
@@ -228,6 +233,8 @@ METHOD(enumerator_t, rdn_part_enumerate, bool,
{OID_EMPLOYEE_NUMBER, ID_PART_RDN_EN},
};
+ VA_ARGS_VGET(args, type, data);
+
while (this->inner->enumerate(this->inner, &oid, &strtype, &inner_data))
{
known_oid = asn1_known_oid(oid);
@@ -263,7 +270,8 @@ METHOD(identification_t, create_part_enumerator, enumerator_t*,
INIT(e,
.inner = create_rdn_enumerator(this->encoded),
.public = {
- .enumerate = (void*)_rdn_part_enumerate,
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _rdn_part_enumerate,
.destroy = _rdn_part_enumerator_destroy,
},
);
diff --git a/src/libstrongswan/utils/leak_detective.c b/src/libstrongswan/utils/leak_detective.c
index ad67c0380..1dfeea557 100644
--- a/src/libstrongswan/utils/leak_detective.c
+++ b/src/libstrongswan/utils/leak_detective.c
@@ -606,6 +606,9 @@ static char *whitelist[] = {
"system__tasking__stages__create_task",
/* in case external threads call into our code */
"thread_current_id",
+ /* FHH IMCs and IMVs */
+ "TNC_IMC_NotifyConnectionChange",
+ "TNC_IMV_NotifyConnectionChange",
};
/**
diff --git a/src/libstrongswan/utils/utils.h b/src/libstrongswan/utils/utils.h
index 0aed842b1..33b8d1956 100644
--- a/src/libstrongswan/utils/utils.h
+++ b/src/libstrongswan/utils/utils.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2008-2015 Tobias Brunner
+ * Copyright (C) 2008-2017 Tobias Brunner
* Copyright (C) 2008 Martin Willi
- * Hochschule fuer Technik Rapperswil
+ * HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -28,6 +28,7 @@
#include <stddef.h>
#include <sys/time.h>
#include <string.h>
+#include <stdarg.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
@@ -141,6 +142,49 @@ void utils_deinit();
#define __VA_ARGS_DISPATCH(func, num) func ## num
/**
+ * Assign variadic arguments to the given variables.
+ *
+ * @note The order and types of the variables are significant and must match the
+ * variadic arguments passed to the function that calls this macro exactly.
+ *
+ * @param last the last argument before ... in the function that calls this
+ * @param ... variable names
+ */
+#define VA_ARGS_GET(last, ...) ({ \
+ va_list _va_args_get_ap; \
+ va_start(_va_args_get_ap, last); \
+ _VA_ARGS_GET_ASGN(__VA_ARGS__) \
+ va_end(_va_args_get_ap); \
+})
+
+/**
+ * Assign variadic arguments from a va_list to the given variables.
+ *
+ * @note The order and types of the variables are significant and must match the
+ * variadic arguments passed to the function that calls this macro exactly.
+ *
+ * @param list the va_list variable in the function that calls this
+ * @param ... variable names
+ */
+#define VA_ARGS_VGET(list, ...) ({ \
+ va_list _va_args_get_ap; \
+ va_copy(_va_args_get_ap, list); \
+ _VA_ARGS_GET_ASGN(__VA_ARGS__) \
+ va_end(_va_args_get_ap); \
+})
+
+#define _VA_ARGS_GET_ASGN(...) VA_ARGS_DISPATCH(_VA_ARGS_GET_ASGN, __VA_ARGS__)(__VA_ARGS__)
+#define _VA_ARGS_GET_ASGN1(v1) __VA_ARGS_GET_ASGN(v1)
+#define _VA_ARGS_GET_ASGN2(v1,v2) __VA_ARGS_GET_ASGN(v1) __VA_ARGS_GET_ASGN(v2)
+#define _VA_ARGS_GET_ASGN3(v1,v2,v3) __VA_ARGS_GET_ASGN(v1) __VA_ARGS_GET_ASGN(v2) \
+ __VA_ARGS_GET_ASGN(v3)
+#define _VA_ARGS_GET_ASGN4(v1,v2,v3,v4) __VA_ARGS_GET_ASGN(v1) __VA_ARGS_GET_ASGN(v2) \
+ __VA_ARGS_GET_ASGN(v3) __VA_ARGS_GET_ASGN(v4)
+#define _VA_ARGS_GET_ASGN5(v1,v2,v3,v4,v5) __VA_ARGS_GET_ASGN(v1) __VA_ARGS_GET_ASGN(v2) \
+ __VA_ARGS_GET_ASGN(v3) __VA_ARGS_GET_ASGN(v4) __VA_ARGS_GET_ASGN(v5)
+#define __VA_ARGS_GET_ASGN(v) v = va_arg(_va_args_get_ap, typeof(v));
+
+/**
* Macro to allocate a sized type.
*/
#define malloc_thing(thing) ((thing*)malloc(sizeof(thing)))