aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht_neighbours.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-08-24 21:59:41 +0200
committerChristian Grothoff <christian@grothoff.org>2022-08-24 21:59:41 +0200
commit829c3366c71b52664b9469b6329f6c51a2394922 (patch)
treed40fede1af82fb35b263f35a514ed5731bec7534 /src/dht/gnunet-service-dht_neighbours.c
parenta53dce1f8aaf497c1f7a23cf4fa3e982f9baabfb (diff)
downloadgnunet-829c3366c71b52664b9469b6329f6c51a2394922.tar.gz
gnunet-829c3366c71b52664b9469b6329f6c51a2394922.zip
-proper ResultMessage validation with new flags
Diffstat (limited to 'src/dht/gnunet-service-dht_neighbours.c')
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 025f22c86..3344824b3 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -2509,14 +2509,21 @@ static enum GNUNET_GenericReturnValue
2509check_dht_p2p_result (void *cls, 2509check_dht_p2p_result (void *cls,
2510 const struct PeerResultMessage *prm) 2510 const struct PeerResultMessage *prm)
2511{ 2511{
2512 uint16_t msize = ntohs (prm->header.size) - sizeof (*prm);
2513 enum GNUNET_DHT_RouteOption ro
2514 = (enum GNUNET_DHT_RouteOption) ntohs (prm->options);
2515 bool truncated = (0 != (ro & GNUNET_DHT_RO_TRUNCATED));
2516 bool tracked = (0 != (ro & GNUNET_DHT_RO_RECORD_ROUTE));
2517
2512 uint16_t get_path_length = ntohs (prm->get_path_length); 2518 uint16_t get_path_length = ntohs (prm->get_path_length);
2513 uint16_t put_path_length = ntohs (prm->put_path_length); 2519 uint16_t put_path_length = ntohs (prm->put_path_length);
2514 uint16_t msize = ntohs (prm->header.size); 2520 size_t vsize = (truncated ? sizeof (struct GNUNET_PeerIdentity) : 0)
2521 + (tracked ? sizeof (struct GNUNET_CRYPTO_EddsaSignature) : 0);
2515 2522
2516 (void) cls; 2523 (void) cls;
2517 if ( (msize < 2524 if ( (msize < vsize) ||
2518 sizeof(struct PeerResultMessage) 2525 (msize - vsize <
2519 + (get_path_length + put_path_length) 2526 (get_path_length + put_path_length)
2520 * sizeof(struct GNUNET_DHT_PathElement)) || 2527 * sizeof(struct GNUNET_DHT_PathElement)) ||
2521 (get_path_length > 2528 (get_path_length >
2522 GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) || 2529 GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) ||