From 78c37de15a06de470cc82e428e268ebf9f1f9d9f Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Thu, 28 Mar 2013 16:50:36 +0100 Subject: [PATCH] Use chunk_from_str in identification_from_string We always have a non-empty string in those cases as "" is now handled as ID_ANY. --- src/libstrongswan/utils/identification.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/libstrongswan/utils/identification.c b/src/libstrongswan/utils/identification.c index 348da627c..ca0e5c93e 100644 --- a/src/libstrongswan/utils/identification.c +++ b/src/libstrongswan/utils/identification.c @@ -915,7 +915,7 @@ identification_t *identification_create_from_string(char *string) else { this = identification_create(ID_KEY_ID); - this->encoded = chunk_clone(chunk_create(string, strlen(string))); + this->encoded = chunk_from_str(strdup(string)); } return &this->public; } @@ -948,11 +948,7 @@ identification_t *identification_create_from_string(char *string) else { /* not IPv4, mostly FQDN */ this = identification_create(ID_FQDN); - this->encoded.len = strlen(string); - if (this->encoded.len) - { - this->encoded.ptr = strdup(string); - } + this->encoded = chunk_from_str(strdup(string)); } return &this->public; } @@ -969,11 +965,7 @@ identification_t *identification_create_from_string(char *string) else { /* not IPv4/6 fallback to KEY_ID */ this = identification_create(ID_KEY_ID); - this->encoded.len = strlen(string); - if (this->encoded.len) - { - this->encoded.ptr = strdup(string); - } + this->encoded = chunk_from_str(strdup(string)); } return &this->public; } @@ -997,7 +989,7 @@ identification_t *identification_create_from_string(char *string) string += 1; this->encoded.len = strlen(string); if (this->encoded.len) - { + { /* if we only got an @ */ this->encoded.ptr = strdup(string); } return &this->public; @@ -1006,11 +998,7 @@ identification_t *identification_create_from_string(char *string) else { this = identification_create(ID_RFC822_ADDR); - this->encoded.len = strlen(string); - if (this->encoded.len) - { - this->encoded.ptr = strdup(string); - } + this->encoded = chunk_from_str(strdup(string)); return &this->public; } }