From 7b9618d4bb1b6bf38877b9b85ad29b4595923c46 Mon Sep 17 00:00:00 2001 From: Omar Tarabai Date: Sun, 24 Aug 2014 18:29:41 +0000 Subject: peerstore: minor fixes --- src/peerstore/peerstore.conf.in | 3 ++- src/peerstore/peerstore.h | 12 ++++++------ src/peerstore/peerstore_common.c | 11 +++++++++++ 3 files changed, 19 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/peerstore/peerstore.conf.in b/src/peerstore/peerstore.conf.in index a6c84ae07..a39b61887 100644 --- a/src/peerstore/peerstore.conf.in +++ b/src/peerstore/peerstore.conf.in @@ -1,6 +1,7 @@ [peerstore] AUTOSTART = @AUTOSTART@ -@UNIXONLY@PORT = 2110 +@JAVAPORT@PORT = 2110 +HOSTNAME = localhost BINARY = gnunet-service-peerstore UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-peerstore.sock UNIX_MATCH_UID = NO diff --git a/src/peerstore/peerstore.h b/src/peerstore/peerstore.h index 94970d906..ef134feef 100644 --- a/src/peerstore/peerstore.h +++ b/src/peerstore/peerstore.h @@ -44,7 +44,7 @@ GNUNET_NETWORK_STRUCT_BEGIN /** * #GNUNET_YES if peer id value set, #GNUNET_NO otherwise */ - uint16_t peer_set; + uint16_t peer_set GNUNET_PACKED; /** * Peer Identity @@ -55,30 +55,30 @@ GNUNET_NETWORK_STRUCT_BEGIN * Size of the sub_system string * Allocated at position 0 after this struct */ - size_t sub_system_size; + uint16_t sub_system_size GNUNET_PACKED; /** * Size of the key string * Allocated at position 1 after this struct */ - size_t key_size; + uint16_t key_size GNUNET_PACKED; /** * Size of value blob * Allocated at position 2 after this struct */ - size_t value_size; + uint16_t value_size GNUNET_PACKED; /** * Expiry time of entry */ - struct GNUNET_TIME_Absolute expiry; + struct GNUNET_TIME_Absolute expiry GNUNET_PACKED; /** * Options, needed only in case of a * store operation */ - enum GNUNET_PEERSTORE_StoreOption options; + enum GNUNET_PEERSTORE_StoreOption options GNUNET_PACKED; }; diff --git a/src/peerstore/peerstore_common.c b/src/peerstore/peerstore_common.c index 1f86fe442..96b428aee 100644 --- a/src/peerstore/peerstore_common.c +++ b/src/peerstore/peerstore_common.c @@ -194,14 +194,25 @@ PEERSTORE_parse_record_message (const struct GNUNET_MessageHeader *message) req_size = ntohs (message->size); if (req_size < sizeof (struct StoreRecordMessage)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Received message with invalid size: (%d < %d).\n", + req_size, sizeof (struct StoreRecordMessage)); return NULL; + } srm = (struct StoreRecordMessage *) message; ss_size = ntohs (srm->sub_system_size); key_size = ntohs (srm->key_size); value_size = ntohs (srm->value_size); if (ss_size + key_size + value_size + sizeof (struct StoreRecordMessage) != req_size) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Received message with invalid sizes: (%d + %d + %d + %d != %d).\n", + ss_size, key_size, value_size, sizeof (struct StoreRecordMessage), + req_size); return NULL; + } record = GNUNET_new (struct GNUNET_PEERSTORE_Record); if (GNUNET_YES == ntohs (srm->peer_set)) { -- cgit v1.2.3