diff options
Diffstat (limited to 'src/libstrongswan/utils/identification.c')
-rw-r--r-- | src/libstrongswan/utils/identification.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/libstrongswan/utils/identification.c b/src/libstrongswan/utils/identification.c index e7eb63bc6..46ac7e890 100644 --- a/src/libstrongswan/utils/identification.c +++ b/src/libstrongswan/utils/identification.c @@ -15,15 +15,12 @@ * for more details. */ -#define _GNU_SOURCE -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> #include <string.h> #include <stdio.h> #include "identification.h" +#include <utils/utils.h> #include <asn1/oid.h> #include <asn1/asn1.h> #include <crypto/hashers/hasher.h> @@ -397,14 +394,24 @@ static status_t atodn(char *src, chunk_t *dn) asn1_t rdn_type; state_t state = SEARCH_OID; status_t status = SUCCESS; + char sep = '\0'; do { switch (state) { case SEARCH_OID: - if (*src != ' ' && *src != '/' && *src != ',' && *src != '\0') + if (!sep && *src == '/') + { /* use / as separator if the string starts with a slash */ + sep = '/'; + break; + } + if (*src != ' ' && *src != '\0') { + if (!sep) + { /* use , as separator by default */ + sep = ','; + } oid.ptr = src; oid.len = 1; state = READ_OID; @@ -444,7 +451,7 @@ static status_t atodn(char *src, chunk_t *dn) { break; } - else if (*src != ',' && *src != '/' && *src != '\0') + else if (*src != sep && *src != '\0') { name.ptr = src; name.len = 1; @@ -457,7 +464,7 @@ static status_t atodn(char *src, chunk_t *dn) state = READ_NAME; /* fall-through */ case READ_NAME: - if (*src != ',' && *src != '/' && *src != '\0') + if (*src != sep && *src != '\0') { name.len++; if (*src == ' ') |