diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-08-24 18:29:41 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-08-24 18:29:41 +0000 |
commit | 7b9618d4bb1b6bf38877b9b85ad29b4595923c46 (patch) | |
tree | b74535d2ce0c0ee5ed3af179eac5ba320cab95c2 /src | |
parent | 1b51c48808587b91655e5798bb81d550c3b2f1a8 (diff) | |
download | gnunet-7b9618d4bb1b6bf38877b9b85ad29b4595923c46.tar.gz gnunet-7b9618d4bb1b6bf38877b9b85ad29b4595923c46.zip |
peerstore: minor fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/peerstore/peerstore.conf.in | 3 | ||||
-rw-r--r-- | src/peerstore/peerstore.h | 12 | ||||
-rw-r--r-- | src/peerstore/peerstore_common.c | 11 |
3 files changed, 19 insertions, 7 deletions
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 @@ | |||
1 | [peerstore] | 1 | [peerstore] |
2 | AUTOSTART = @AUTOSTART@ | 2 | AUTOSTART = @AUTOSTART@ |
3 | @UNIXONLY@PORT = 2110 | 3 | @JAVAPORT@PORT = 2110 |
4 | HOSTNAME = localhost | ||
4 | BINARY = gnunet-service-peerstore | 5 | BINARY = gnunet-service-peerstore |
5 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-peerstore.sock | 6 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-peerstore.sock |
6 | UNIX_MATCH_UID = NO | 7 | 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 | |||
44 | /** | 44 | /** |
45 | * #GNUNET_YES if peer id value set, #GNUNET_NO otherwise | 45 | * #GNUNET_YES if peer id value set, #GNUNET_NO otherwise |
46 | */ | 46 | */ |
47 | uint16_t peer_set; | 47 | uint16_t peer_set GNUNET_PACKED; |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Peer Identity | 50 | * Peer Identity |
@@ -55,30 +55,30 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
55 | * Size of the sub_system string | 55 | * Size of the sub_system string |
56 | * Allocated at position 0 after this struct | 56 | * Allocated at position 0 after this struct |
57 | */ | 57 | */ |
58 | size_t sub_system_size; | 58 | uint16_t sub_system_size GNUNET_PACKED; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Size of the key string | 61 | * Size of the key string |
62 | * Allocated at position 1 after this struct | 62 | * Allocated at position 1 after this struct |
63 | */ | 63 | */ |
64 | size_t key_size; | 64 | uint16_t key_size GNUNET_PACKED; |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * Size of value blob | 67 | * Size of value blob |
68 | * Allocated at position 2 after this struct | 68 | * Allocated at position 2 after this struct |
69 | */ | 69 | */ |
70 | size_t value_size; | 70 | uint16_t value_size GNUNET_PACKED; |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * Expiry time of entry | 73 | * Expiry time of entry |
74 | */ | 74 | */ |
75 | struct GNUNET_TIME_Absolute expiry; | 75 | struct GNUNET_TIME_Absolute expiry GNUNET_PACKED; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Options, needed only in case of a | 78 | * Options, needed only in case of a |
79 | * store operation | 79 | * store operation |
80 | */ | 80 | */ |
81 | enum GNUNET_PEERSTORE_StoreOption options; | 81 | enum GNUNET_PEERSTORE_StoreOption options GNUNET_PACKED; |
82 | 82 | ||
83 | }; | 83 | }; |
84 | 84 | ||
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) | |||
194 | 194 | ||
195 | req_size = ntohs (message->size); | 195 | req_size = ntohs (message->size); |
196 | if (req_size < sizeof (struct StoreRecordMessage)) | 196 | if (req_size < sizeof (struct StoreRecordMessage)) |
197 | { | ||
198 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
199 | "Received message with invalid size: (%d < %d).\n", | ||
200 | req_size, sizeof (struct StoreRecordMessage)); | ||
197 | return NULL; | 201 | return NULL; |
202 | } | ||
198 | srm = (struct StoreRecordMessage *) message; | 203 | srm = (struct StoreRecordMessage *) message; |
199 | ss_size = ntohs (srm->sub_system_size); | 204 | ss_size = ntohs (srm->sub_system_size); |
200 | key_size = ntohs (srm->key_size); | 205 | key_size = ntohs (srm->key_size); |
201 | value_size = ntohs (srm->value_size); | 206 | value_size = ntohs (srm->value_size); |
202 | if (ss_size + key_size + value_size + sizeof (struct StoreRecordMessage) != | 207 | if (ss_size + key_size + value_size + sizeof (struct StoreRecordMessage) != |
203 | req_size) | 208 | req_size) |
209 | { | ||
210 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
211 | "Received message with invalid sizes: (%d + %d + %d + %d != %d).\n", | ||
212 | ss_size, key_size, value_size, sizeof (struct StoreRecordMessage), | ||
213 | req_size); | ||
204 | return NULL; | 214 | return NULL; |
215 | } | ||
205 | record = GNUNET_new (struct GNUNET_PEERSTORE_Record); | 216 | record = GNUNET_new (struct GNUNET_PEERSTORE_Record); |
206 | if (GNUNET_YES == ntohs (srm->peer_set)) | 217 | if (GNUNET_YES == ntohs (srm->peer_set)) |
207 | { | 218 | { |