aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2010-08-31 15:34:08 +0200
committerMartin Willi <martin@revosec.ch>2010-08-31 15:34:45 +0200
commit4332b5af893281c7f72954dc3d551003e7017014 (patch)
treecdd4110a559ca66d39c15198c8a0500a6e47256d /src
parent64d24679df6fe0807463929bd0917f614f2ca236 (diff)
downloadstrongswan-4332b5af893281c7f72954dc3d551003e7017014.tar.bz2
strongswan-4332b5af893281c7f72954dc3d551003e7017014.tar.xz
Do not strdup() zero length strings in identification_create_from_string()
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/utils/identification.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/libstrongswan/utils/identification.c b/src/libstrongswan/utils/identification.c
index 3caeb8f0e..0696c1030 100644
--- a/src/libstrongswan/utils/identification.c
+++ b/src/libstrongswan/utils/identification.c
@@ -930,7 +930,11 @@ identification_t *identification_create_from_string(char *string)
else
{ /* not IPv4, mostly FQDN */
this = identification_create(ID_FQDN);
- this->encoded = chunk_create(strdup(string), strlen(string));
+ this->encoded.len = strlen(string);
+ if (this->encoded.len)
+ {
+ this->encoded.ptr = strdup(string);
+ }
}
return &this->public;
}
@@ -947,7 +951,11 @@ identification_t *identification_create_from_string(char *string)
else
{ /* not IPv4/6 fallback to KEY_ID */
this = identification_create(ID_KEY_ID);
- this->encoded = chunk_create(strdup(string), strlen(string));
+ this->encoded.len = strlen(string);
+ if (this->encoded.len)
+ {
+ this->encoded.ptr = strdup(string);
+ }
}
return &this->public;
}
@@ -969,14 +977,22 @@ identification_t *identification_create_from_string(char *string)
{
this = identification_create(ID_FQDN);
string += 1;
- this->encoded = chunk_create(strdup(string), strlen(string));
+ this->encoded.len = strlen(string);
+ if (this->encoded.len)
+ {
+ this->encoded.ptr = strdup(string);
+ }
return &this->public;
}
}
else
{
this = identification_create(ID_RFC822_ADDR);
- this->encoded = chunk_create(strdup(string), strlen(string));
+ this->encoded.len = strlen(string);
+ if (this->encoded.len)
+ {
+ this->encoded.ptr = strdup(string);
+ }
return &this->public;
}
}