diff options
author | t3sserakt <t3ss@posteo.de> | 2018-02-16 18:45:25 +0100 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2018-02-16 18:57:10 +0100 |
commit | abd12cabccd56f7574548d6d576b772220389b7b (patch) | |
tree | 3df9fe2bc1dfa2e86ccff1148df5f47cc82b0765 /src/multicast | |
parent | d58a3cdedff02a94f1aba715b6ea75e79156cf36 (diff) | |
download | gnunet-abd12cabccd56f7574548d6d576b772220389b7b.tar.gz gnunet-abd12cabccd56f7574548d6d576b772220389b7b.zip |
fixed codesonar: 463.634, 1216.1564, 547.830, 1215.1563, 441.612, 478.650
Signed-off-by: t3sserakt <t3ss@posteo.de>
Diffstat (limited to 'src/multicast')
-rw-r--r-- | src/multicast/gnunet-service-multicast.c | 27 | ||||
-rw-r--r-- | src/multicast/multicast.h | 5 |
2 files changed, 20 insertions, 12 deletions
diff --git a/src/multicast/gnunet-service-multicast.c b/src/multicast/gnunet-service-multicast.c index ab7d1c5a0..66f18da9f 100644 --- a/src/multicast/gnunet-service-multicast.c +++ b/src/multicast/gnunet-service-multicast.c | |||
@@ -1450,8 +1450,12 @@ check_client_member_join (void *cls, | |||
1450 | uint16_t msg_size = ntohs (msg->header.size); | 1450 | uint16_t msg_size = ntohs (msg->header.size); |
1451 | struct GNUNET_PeerIdentity *relays = (struct GNUNET_PeerIdentity *) &msg[1]; | 1451 | struct GNUNET_PeerIdentity *relays = (struct GNUNET_PeerIdentity *) &msg[1]; |
1452 | uint32_t relay_count = ntohl (msg->relay_count); | 1452 | uint32_t relay_count = ntohl (msg->relay_count); |
1453 | if (relay_count > MAX_RELAY_COUNT) return GNUNET_SYSERR; | 1453 | if (UINT32_MAX - relay_count > sizeof (*relays)){ |
1454 | uint16_t relay_size = relay_count * sizeof (*relays); | 1454 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1455 | "relay_size exceeds UINT32_MAX!"); | ||
1456 | return GNUNET_SYSERR; | ||
1457 | } | ||
1458 | uint32_t relay_size = relay_count * sizeof (*relays); | ||
1455 | struct GNUNET_MessageHeader *join_msg = NULL; | 1459 | struct GNUNET_MessageHeader *join_msg = NULL; |
1456 | uint16_t join_msg_size = 0; | 1460 | uint16_t join_msg_size = 0; |
1457 | if (sizeof (*msg) + relay_size + sizeof (struct GNUNET_MessageHeader) | 1461 | if (sizeof (*msg) + relay_size + sizeof (struct GNUNET_MessageHeader) |
@@ -1460,11 +1464,19 @@ check_client_member_join (void *cls, | |||
1460 | join_msg = (struct GNUNET_MessageHeader *) | 1464 | join_msg = (struct GNUNET_MessageHeader *) |
1461 | (((char *) &msg[1]) + relay_size); | 1465 | (((char *) &msg[1]) + relay_size); |
1462 | join_msg_size = ntohs (join_msg->size); | 1466 | join_msg_size = ntohs (join_msg->size); |
1467 | if (UINT16_MAX - join_msg_size > sizeof (struct MulticastJoinRequestMessage)){ | ||
1468 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1469 | "join_msg_size exceeds UINT16_MAX!"); | ||
1470 | return GNUNET_SYSERR; | ||
1471 | } | ||
1472 | } | ||
1473 | if (msg_size != (sizeof (*msg) + relay_size + join_msg_size)){ | ||
1474 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1475 | "msg_size does not match real size of message!"); | ||
1476 | return GNUNET_SYSERR; | ||
1477 | }else{ | ||
1478 | return GNUNET_OK; | ||
1463 | } | 1479 | } |
1464 | return | ||
1465 | msg_size == (sizeof (*msg) + relay_size + join_msg_size) | ||
1466 | ? GNUNET_OK | ||
1467 | : GNUNET_SYSERR; | ||
1468 | } | 1480 | } |
1469 | 1481 | ||
1470 | 1482 | ||
@@ -1888,6 +1900,7 @@ handle_client_replay_request (void *cls, | |||
1888 | else | 1900 | else |
1889 | { | 1901 | { |
1890 | /* FIXME: not yet connected to origin */ | 1902 | /* FIXME: not yet connected to origin */ |
1903 | |||
1891 | GNUNET_assert (0); | 1904 | GNUNET_assert (0); |
1892 | GNUNET_SERVICE_client_drop (client); | 1905 | GNUNET_SERVICE_client_drop (client); |
1893 | return; | 1906 | return; |
@@ -1976,7 +1989,7 @@ static int | |||
1976 | check_client_replay_response (void *cls, | 1989 | check_client_replay_response (void *cls, |
1977 | const struct MulticastReplayResponseMessage *res) | 1990 | const struct MulticastReplayResponseMessage *res) |
1978 | { | 1991 | { |
1979 | const struct GNUNET_MessageHeader *msg = &res->header; | 1992 | const struct GNUNET_MessageHeader *msg; |
1980 | if (GNUNET_MULTICAST_REC_OK == res->error_code) | 1993 | if (GNUNET_MULTICAST_REC_OK == res->error_code) |
1981 | { | 1994 | { |
1982 | msg = GNUNET_MQ_extract_nested_mh (res); | 1995 | msg = GNUNET_MQ_extract_nested_mh (res); |
diff --git a/src/multicast/multicast.h b/src/multicast/multicast.h index 8ff6af237..aeb3c0b41 100644 --- a/src/multicast/multicast.h +++ b/src/multicast/multicast.h | |||
@@ -30,11 +30,6 @@ | |||
30 | #include "platform.h" | 30 | #include "platform.h" |
31 | #include "gnunet_multicast_service.h" | 31 | #include "gnunet_multicast_service.h" |
32 | 32 | ||
33 | /* FIXME: What is a reasonable value here? | ||
34 | * Should it be in an include file that clients can also see? | ||
35 | */ | ||
36 | #define MAX_RELAY_COUNT 123 | ||
37 | |||
38 | GNUNET_NETWORK_STRUCT_BEGIN | 33 | GNUNET_NETWORK_STRUCT_BEGIN |
39 | 34 | ||
40 | 35 | ||