Check rng return value when generating Transaction IDs in DHCP plugin
authorTobias Brunner <tobias@strongswan.org>
Mon, 25 Jun 2012 13:56:31 +0000 (15:56 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 16 Jul 2012 12:53:36 +0000 (14:53 +0200)
src/libcharon/plugins/dhcp/dhcp_socket.c

index b4e9af7..8f976ae 100644 (file)
@@ -366,7 +366,11 @@ METHOD(dhcp_socket_t, enroll, dhcp_transaction_t*,
        u_int32_t id;
        int try;
 
-       this->rng->get_bytes(this->rng, sizeof(id), (u_int8_t*)&id);
+       if (!this->rng->get_bytes(this->rng, sizeof(id), (u_int8_t*)&id))
+       {
+               DBG1(DBG_CFG, "DHCP DISCOVER failed, no transaction ID");
+               return NULL;
+       }
        transaction = dhcp_transaction_create(id, identity);
 
        this->mutex->lock(this->mutex);