diff options
author | Martin Willi <martin@revosec.ch> | 2010-06-18 09:18:49 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2010-07-28 10:54:48 +0200 |
commit | c118559afec96f5cd18509b9157b9c07724d550c (patch) | |
tree | 0b9d344d7930f026619d52c2c590e5b5eb8474a6 | |
parent | 018543f3a8b620c0604e0598cab72425569b2a15 (diff) | |
download | strongswan-c118559afec96f5cd18509b9157b9c07724d550c.tar.bz2 strongswan-c118559afec96f5cd18509b9157b9c07724d550c.tar.xz |
Fix use of snprintf() in IETF attributes to string conversion
-rw-r--r-- | src/libstrongswan/credentials/ietf_attributes/ietf_attributes.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libstrongswan/credentials/ietf_attributes/ietf_attributes.c b/src/libstrongswan/credentials/ietf_attributes/ietf_attributes.c index ff3ddeb6f..de5b85bae 100644 --- a/src/libstrongswan/credentials/ietf_attributes/ietf_attributes.c +++ b/src/libstrongswan/credentials/ietf_attributes/ietf_attributes.c @@ -159,7 +159,7 @@ static char* get_string(private_ietf_attributes_t *this) enumerator = this->list->create_enumerator(this->list); while (enumerator->enumerate(enumerator, &attr)) { - int written = 0; + int written; if (first) { @@ -168,8 +168,12 @@ static char* get_string(private_ietf_attributes_t *this) else { written = snprintf(pos, len, ", "); + if (written < 0 || written >= len) + { + break; + } pos += written; - len -= written; + len -= written; } switch (attr->type) @@ -194,8 +198,13 @@ static char* get_string(private_ietf_attributes_t *this) break; } default: + written = 0; break; } + if (written < 0 || written >= len) + { + break; + } pos += written; len -= written; } |