diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-12-01 16:17:23 +0900 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-12-01 16:17:23 +0900 |
commit | 5e746cc2d4f4f17b64f1322e28efa7f65c85cab4 (patch) | |
tree | d203d96053ad1afd3ea9eb742838dde4249d6f19 /src | |
parent | dd33576598fe43f8f224e896a63e6c354ee514ea (diff) | |
download | gnunet-5e746cc2d4f4f17b64f1322e28efa7f65c85cab4.tar.gz gnunet-5e746cc2d4f4f17b64f1322e28efa7f65c85cab4.zip |
-there is no reason for that variable to be on the heap
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-tng.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index 32c8b816d..b21406a3a 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -8151,13 +8151,11 @@ handle_dv_box (void *cls, const struct TransportDVBoxMessage *dvb) | |||
8151 | const char *enc_payload = (const char *) &hops[num_hops]; | 8151 | const char *enc_payload = (const char *) &hops[num_hops]; |
8152 | uint16_t enc_payload_size = | 8152 | uint16_t enc_payload_size = |
8153 | size - (num_hops * sizeof(struct GNUNET_PeerIdentity)); | 8153 | size - (num_hops * sizeof(struct GNUNET_PeerIdentity)); |
8154 | struct DVKeyState *key; | 8154 | struct DVKeyState key; |
8155 | struct GNUNET_HashCode hmac; | 8155 | struct GNUNET_HashCode hmac; |
8156 | const char *hdr; | 8156 | const char *hdr; |
8157 | size_t hdr_len; | 8157 | size_t hdr_len; |
8158 | 8158 | ||
8159 | key = GNUNET_new (struct DVKeyState); | ||
8160 | |||
8161 | if (GNUNET_EXTRA_LOGGING > 0) | 8159 | if (GNUNET_EXTRA_LOGGING > 0) |
8162 | { | 8160 | { |
8163 | char *path; | 8161 | char *path; |
@@ -8232,13 +8230,13 @@ handle_dv_box (void *cls, const struct TransportDVBoxMessage *dvb) | |||
8232 | GNUNET_NO); | 8230 | GNUNET_NO); |
8233 | cmc->total_hops = ntohs (dvb->total_hops); | 8231 | cmc->total_hops = ntohs (dvb->total_hops); |
8234 | 8232 | ||
8235 | dh_key_derive_eph_pub (&dvb->ephemeral_key, &dvb->iv, key); | 8233 | dh_key_derive_eph_pub (&dvb->ephemeral_key, &dvb->iv, &key); |
8236 | hdr = (const char *) &dvb[1]; | 8234 | hdr = (const char *) &dvb[1]; |
8237 | hdr_len = ntohs (dvb->orig_size) - sizeof(*dvb) - sizeof(struct | 8235 | hdr_len = ntohs (dvb->orig_size) - sizeof(*dvb) - sizeof(struct |
8238 | GNUNET_PeerIdentity) | 8236 | GNUNET_PeerIdentity) |
8239 | * ntohs (dvb->total_hops); | 8237 | * ntohs (dvb->total_hops); |
8240 | 8238 | ||
8241 | dv_hmac (key, &hmac, hdr, hdr_len); | 8239 | dv_hmac (&key, &hmac, hdr, hdr_len); |
8242 | if (0 != GNUNET_memcmp (&hmac, &dvb->hmac)) | 8240 | if (0 != GNUNET_memcmp (&hmac, &dvb->hmac)) |
8243 | { | 8241 | { |
8244 | /* HMAC mismatch, discard! */ | 8242 | /* HMAC mismatch, discard! */ |
@@ -8257,7 +8255,7 @@ handle_dv_box (void *cls, const struct TransportDVBoxMessage *dvb) | |||
8257 | 8255 | ||
8258 | GNUNET_assert (hdr_len >= | 8256 | GNUNET_assert (hdr_len >= |
8259 | sizeof(ppay) + sizeof(struct GNUNET_MessageHeader)); | 8257 | sizeof(ppay) + sizeof(struct GNUNET_MessageHeader)); |
8260 | if (GNUNET_OK != dv_decrypt (key, &ppay, hdr, sizeof(ppay))) | 8258 | if (GNUNET_OK != dv_decrypt (&key, &ppay, hdr, sizeof(ppay))) |
8261 | { | 8259 | { |
8262 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 8260 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
8263 | "Error decrypting DV payload header\n"); | 8261 | "Error decrypting DV payload header\n"); |
@@ -8265,7 +8263,8 @@ handle_dv_box (void *cls, const struct TransportDVBoxMessage *dvb) | |||
8265 | finish_cmc_handling (cmc); | 8263 | finish_cmc_handling (cmc); |
8266 | return; | 8264 | return; |
8267 | } | 8265 | } |
8268 | if (GNUNET_OK != dv_decrypt (key, &body, &hdr[sizeof(ppay)], hdr_len - sizeof(ppay))) | 8266 | if (GNUNET_OK != dv_decrypt (&key, &body, |
8267 | &hdr[sizeof(ppay)], hdr_len - sizeof(ppay))) | ||
8269 | { | 8268 | { |
8270 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 8269 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
8271 | "Error decrypting DV payload\n"); | 8270 | "Error decrypting DV payload\n"); |
@@ -8273,7 +8272,7 @@ handle_dv_box (void *cls, const struct TransportDVBoxMessage *dvb) | |||
8273 | finish_cmc_handling (cmc); | 8272 | finish_cmc_handling (cmc); |
8274 | return; | 8273 | return; |
8275 | } | 8274 | } |
8276 | dv_key_clean (key); | 8275 | dv_key_clean (&key); |
8277 | if (ntohs (mh->size) != sizeof(body)) | 8276 | if (ntohs (mh->size) != sizeof(body)) |
8278 | { | 8277 | { |
8279 | GNUNET_break_op (0); | 8278 | GNUNET_break_op (0); |