summaryrefslogtreecommitdiff
path: root/src/libfast/session.c
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-01-02 14:18:20 +0100
committerYves-Alexis Perez <corsac@debian.org>2013-01-02 14:18:20 +0100
commitc1343b3278cdf99533b7902744d15969f9d6fdc1 (patch)
treed5ed3dc5677a59260ec41cd39bb284d3e94c91b3 /src/libfast/session.c
parentb34738ed08c2227300d554b139e2495ca5da97d6 (diff)
downloadvyos-strongswan-c1343b3278cdf99533b7902744d15969f9d6fdc1.tar.gz
vyos-strongswan-c1343b3278cdf99533b7902744d15969f9d6fdc1.zip
Imported Upstream version 5.0.1
Diffstat (limited to 'src/libfast/session.c')
-rw-r--r--src/libfast/session.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/libfast/session.c b/src/libfast/session.c
index 1d9ed0107..cf14dbeb6 100644
--- a/src/libfast/session.c
+++ b/src/libfast/session.c
@@ -78,20 +78,24 @@ METHOD(session_t, add_filter, void,
/**
* Create a session ID and a cookie
*/
-static void create_sid(private_session_t *this)
+static bool create_sid(private_session_t *this)
{
char buf[COOKIE_LEN];
rng_t *rng;
- memset(buf, 0, sizeof(buf));
- memset(this->sid, 0, sizeof(this->sid));
rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
- if (rng)
+ if (!rng)
+ {
+ return FALSE;
+ }
+ if (!rng->get_bytes(rng, sizeof(buf), buf))
{
- rng->get_bytes(rng, sizeof(buf), buf);
rng->destroy(rng);
+ return FALSE;
}
+ rng->destroy(rng);
chunk_to_hex(chunk_create(buf, sizeof(buf)), this->sid, FALSE);
+ return TRUE;
}
/**
@@ -212,7 +216,11 @@ session_t *session_create(context_t *context)
.filters = linked_list_create(),
.context = context,
);
- create_sid(this);
+ if (!create_sid(this))
+ {
+ destroy(this);
+ return NULL;
+ }
return &this->public;
}