diff options
author | Bart Polot <bart@net.in.tum.de> | 2015-04-27 19:15:24 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2015-04-27 19:15:24 +0000 |
commit | c6bc3a3896a39cb1bdfbd3079e24f98ab28aeb00 (patch) | |
tree | 3df933afe0bb3f00d51407026895d80a75c159e3 | |
parent | ce17101938e3809d6a59a13903e4a82e189d1c49 (diff) |
- adjust checks for different encryption overheads
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.c | 12 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_tunnel.c | 7 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index 4ca8f2daa8..0a6d537bb4 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c @@ -2235,7 +2235,8 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer, const struct GNUNET_CADET_Encrypted *msg; const struct GNUNET_CADET_Hash* cid; struct CadetConnection *c; - size_t expected_size; + size_t minumum_size; + size_t overhead; uint32_t pid; uint32_t ttl; int fwd; @@ -2244,11 +2245,14 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer, cid = &msg->cid; log_message (message, peer, cid); - expected_size = sizeof (struct GNUNET_CADET_Encrypted) - + sizeof (struct GNUNET_MessageHeader); + if (GNUNET_MESSAGE_TYPE_CADET_AX == ntohs (message->type)) + overhead = sizeof (struct GNUNET_CADET_AX); + else + overhead = sizeof (struct GNUNET_CADET_Encrypted); + minumum_size = sizeof (struct GNUNET_MessageHeader) + overhead; c = connection_get (cid); pid = ntohl (msg->pid); - fwd = check_message (message, expected_size, cid, c, peer, pid); + fwd = check_message (message, minumum_size, cid, c, peer, pid); /* If something went wrong, discard message. */ if (GNUNET_SYSERR == fwd) diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c index 9c7493aa2a..06f358e75c 100644 --- a/src/cadet/gnunet-service-cadet_tunnel.c +++ b/src/cadet/gnunet-service-cadet_tunnel.c @@ -2684,14 +2684,15 @@ void GCT_handle_encrypted (struct CadetTunnel *t, const struct GNUNET_MessageHeader *msg) { - size_t size = ntohs (msg->size); + uint16_t size = ntohs (msg->size); + char cbuf [size]; size_t payload_size; int decrypted_size; - char cbuf [size]; - uint16_t type = ntohs (msg->type); + uint16_t type; struct GNUNET_MessageHeader *msgh; unsigned int off; + type = ntohs (msg->type); if (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED == type) { const struct GNUNET_CADET_Encrypted *emsg; |