From: Tobias Brunner Date: Thu, 28 Mar 2013 15:50:36 +0000 (+0100) Subject: Use chunk_from_str in identification_from_string X-Git-Tag: 5.1.0dr1~129^2~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=78c37de15a06de470cc82e428e268ebf9f1f9d9f;p=thirdparty%2Fstrongswan.git 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. --- diff --git a/src/libstrongswan/utils/identification.c b/src/libstrongswan/utils/identification.c index 348da627c9..ca0e5c93e0 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; } }