aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-07-18 16:45:10 +0200
committerMartin Willi <martin@revosec.ch>2013-07-18 16:45:10 +0200
commitcb6c4e0430d5dd2aba9dfa0ef5f2e4f5b0c6455b (patch)
treea92ac315264fbf41dd336f24daea76aa0698e1de /src
parentc3b8335cfb1def38c0c575d607274c2fc8e9329b (diff)
downloadstrongswan-cb6c4e0430d5dd2aba9dfa0ef5f2e4f5b0c6455b.tar.bz2
strongswan-cb6c4e0430d5dd2aba9dfa0ef5f2e4f5b0c6455b.tar.xz
identification: parse identities having a "@@" prefix as ID_RFC822_ADDR
Original patch by Gerald Richter.
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/utils/identification.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/libstrongswan/utils/identification.c b/src/libstrongswan/utils/identification.c
index 06ec533ea..5df3e5fe2 100644
--- a/src/libstrongswan/utils/identification.c
+++ b/src/libstrongswan/utils/identification.c
@@ -1000,23 +1000,23 @@ identification_t *identification_create_from_string(char *string)
{
if (*string == '@')
{
- if (*(string + 1) == '#')
+ string++;
+ if (*string == '#')
{
this = identification_create(ID_KEY_ID);
- string += 2;
- this->encoded = chunk_from_hex(
- chunk_create(string, strlen(string)), NULL);
+ this->encoded = chunk_from_hex(chunk_from_str(string + 1), NULL);
+ return &this->public;
+ }
+ else if (*string == '@')
+ {
+ this = identification_create(ID_USER_FQDN);
+ this->encoded = chunk_clone(chunk_from_str(string + 1));
return &this->public;
}
else
{
this = identification_create(ID_FQDN);
- string += 1;
- this->encoded.len = strlen(string);
- if (this->encoded.len)
- { /* if we only got an @ */
- this->encoded.ptr = strdup(string);
- }
+ this->encoded = chunk_clone(chunk_from_str(string));
return &this->public;
}
}
@@ -1093,4 +1093,3 @@ identification_t *identification_create_from_sockaddr(sockaddr_t *sockaddr)
}
}
}
-