diff options
author | Rene Mayrhofer <rene@mayrhofer.eu.org> | 2008-10-29 20:30:44 +0000 |
---|---|---|
committer | Rene Mayrhofer <rene@mayrhofer.eu.org> | 2008-10-29 20:30:44 +0000 |
commit | 74f0bbfc53cb5fa519e4e27ece53735ab51b397c (patch) | |
tree | 0dbab9c835be15577ff05b474b6361bb326d66ce /src/libstrongswan/utils | |
parent | 5c1fa2516bda1ccf8eb00178c0beb196c2020a94 (diff) | |
download | vyos-strongswan-74f0bbfc53cb5fa519e4e27ece53735ab51b397c.tar.gz vyos-strongswan-74f0bbfc53cb5fa519e4e27ece53735ab51b397c.zip |
- New upstream release.
Diffstat (limited to 'src/libstrongswan/utils')
-rw-r--r-- | src/libstrongswan/utils/enumerator.c | 141 | ||||
-rw-r--r-- | src/libstrongswan/utils/enumerator.h | 15 | ||||
-rw-r--r-- | src/libstrongswan/utils/identification.c | 6 | ||||
-rw-r--r-- | src/libstrongswan/utils/identification.h | 18 | ||||
-rw-r--r-- | src/libstrongswan/utils/leak_detective.c | 5 |
5 files changed, 177 insertions, 8 deletions
diff --git a/src/libstrongswan/utils/enumerator.c b/src/libstrongswan/utils/enumerator.c index cac5d73fa..4ebc2e097 100644 --- a/src/libstrongswan/utils/enumerator.c +++ b/src/libstrongswan/utils/enumerator.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: enumerator.c 3589 2008-03-13 14:14:44Z martin $ + * $Id: enumerator.c 4142 2008-07-02 08:09:07Z martin $ */ #include "enumerator.h" @@ -154,6 +154,145 @@ enumerator_t* enumerator_create_directory(char *path) } /** + * Enumerator implementation for directory enumerator + */ +typedef struct { + /** implements enumerator_t */ + enumerator_t public; + /** string to parse */ + char *string; + /** current position */ + char *pos; + /** separater chars */ + char *sep; + /** trim chars */ + char *trim; +} token_enum_t; + +/** + * Implementation of enumerator_create_token().destroy + */ +static void destroy_token_enum(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) +{ + char *pos = NULL, *tmp, *sep, *trim; + bool last = FALSE; + + /* trim leading characters/separators */ + while (*this->pos) + { + trim = this->trim; + while (*trim) + { + if (*trim == *this->pos) + { + this->pos++; + break; + } + trim++; + } + sep = this->sep; + while (*sep) + { + if (*sep == *this->pos) + { + this->pos++; + break; + } + sep++; + } + if (!*trim && !*sep) + { + break; + } + } + + /* find separators */ + sep = this->sep; + while (*sep) + { + tmp = strchr(this->pos, *sep); + if (tmp && (pos == NULL || tmp < pos)) + { + pos = tmp; + } + sep++; + } + *token = this->pos; + if (pos) + { + *pos = '\0'; + this->pos = pos + 1; + } + else + { + last = TRUE; + pos = this->pos = strchr(this->pos, '\0'); + } + + /* trim trailing characters/separators */ + pos--; + while (pos >= *token) + { + trim = this->trim; + while (*trim) + { + if (*trim == *pos) + { + *(pos--) = '\0'; + break; + } + trim++; + } + sep = this->sep; + while (*sep) + { + if (*sep == *pos) + { + *(pos--) = '\0'; + break; + } + sep++; + } + if (!*trim && !*sep) + { + break; + } + } + + if (!last || pos > *token) + { + return TRUE; + } + return FALSE; +} + +/** + * See header + */ +enumerator_t* enumerator_create_token(char *string, char *sep, char *trim) +{ + token_enum_t *enumerator = malloc_thing(token_enum_t); + + 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; + + return &enumerator->public; +} + +/** * enumerator for nested enumerations */ typedef struct { diff --git a/src/libstrongswan/utils/enumerator.h b/src/libstrongswan/utils/enumerator.h index 6b91fee72..d82f650db 100644 --- a/src/libstrongswan/utils/enumerator.h +++ b/src/libstrongswan/utils/enumerator.h @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: enumerator.h 3589 2008-03-13 14:14:44Z martin $ + * $Id: enumerator.h 4142 2008-07-02 08:09:07Z martin $ */ /** @@ -98,6 +98,19 @@ enumerator_t *enumerator_create_single(void *item, void (*cleanup)(void *item)); enumerator_t* enumerator_create_directory(char *path); /** + * Create an enumerator over tokens of a string. + * + * Tokens are separated by one of the characters in sep and trimmed by the + * characters in trim. + * + * @param string string to parse + * @param sep separator characters + * @param trim characters to trim from tokens + * @return enumerator over char* tokens + */ +enumerator_t* enumerator_create_token(char *string, char *sep, char *trim); + +/** * Creates an enumerator which enumerates over enumerated enumerators :-). * * The variable argument list of enumeration values is limit to 5. diff --git a/src/libstrongswan/utils/identification.c b/src/libstrongswan/utils/identification.c index 39d49bf6c..db442e9ab 100644 --- a/src/libstrongswan/utils/identification.c +++ b/src/libstrongswan/utils/identification.c @@ -13,7 +13,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: identification.c 4064 2008-06-13 15:10:01Z martin $ + * $Id: identification.c 4344 2008-09-17 02:17:01Z andreas $ */ #define _GNU_SOURCE @@ -915,6 +915,8 @@ static int print(FILE *stream, const struct printf_info *info, case ID_FQDN: case ID_RFC822_ADDR: case ID_DER_ASN1_GN_URI: + case ID_EAP: + case ID_IETF_ATTR_STRING: proper = sanitize_chunk(this->encoded); snprintf(buf, sizeof(buf), "%.*s", proper.len, proper.ptr); chunk_free(&proper); @@ -1169,6 +1171,8 @@ identification_t *identification_create_from_encoding(id_type_t type, chunk_t en case ID_PUBKEY_INFO_SHA1: case ID_PUBKEY_SHA1: case ID_CERT_DER_SHA1: + case ID_EAP: + case ID_IETF_ATTR_STRING: default: break; } diff --git a/src/libstrongswan/utils/identification.h b/src/libstrongswan/utils/identification.h index 591909411..3b895961d 100644 --- a/src/libstrongswan/utils/identification.h +++ b/src/libstrongswan/utils/identification.h @@ -13,7 +13,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: identification.h 3838 2008-04-18 11:24:45Z tobias $ + * $Id: identification.h 4344 2008-09-17 02:17:01Z andreas $ */ /** @@ -131,17 +131,27 @@ enum id_type_t { /** * SHA1 hash over PKCS#1 subjectPublicKeyInfo */ - ID_PUBKEY_INFO_SHA1, + ID_PUBKEY_INFO_SHA1 = 202, /** * SHA1 hash over PKCS#1 subjectPublicKey */ - ID_PUBKEY_SHA1, + ID_PUBKEY_SHA1 = 203, /** * SHA1 hash of the binary DER encoding of a certificate */ - ID_CERT_DER_SHA1, + ID_CERT_DER_SHA1 = 204, + + /** + * Generic EAP identity + */ + ID_EAP = 205, + + /** + * IETF Attribute Syntax String (RFC 3281) + */ + ID_IETF_ATTR_STRING = 206, }; /** diff --git a/src/libstrongswan/utils/leak_detective.c b/src/libstrongswan/utils/leak_detective.c index cff5a1c81..bc7f56ebd 100644 --- a/src/libstrongswan/utils/leak_detective.c +++ b/src/libstrongswan/utils/leak_detective.c @@ -12,7 +12,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * - * $Id: leak_detective.c 4044 2008-06-06 15:05:54Z martin $ + * $Id: leak_detective.c 4311 2008-08-28 16:27:48Z martin $ */ #ifdef HAVE_DLADDR @@ -262,6 +262,7 @@ char *whitelist[] = { /* ignore dlopen, as we do not dlclose to get proper leak reports */ "dlopen", "dlerror", + "dlclose", /* mysql functions */ "mysql_init_character_set", "init_client_errs", @@ -277,6 +278,7 @@ char *whitelist[] = { /* OpenSSL */ "RSA_new_method", "DH_new_method", + "ENGINE_load_builtin_engines", }; /** @@ -558,6 +560,7 @@ leak_detective_t *leak_detective_create() if (getenv("LEAK_DETECTIVE_DISABLE") == NULL) { + lib->leak_detective = TRUE; install_hooks(); } return &this->public; |