diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-03-12 10:18:53 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-03-12 10:18:53 +0000 |
commit | f178ee5c79255d00eec5ed421d2e503b8d176fd0 (patch) | |
tree | 763cd0fda3c59d96216257d2b5487fe17a7d091f /src/gns/plugin_block_gns.c | |
parent | fe61feeb1cdced8020f352289a86f61e3f02d1ad (diff) | |
download | gnunet-f178ee5c79255d00eec5ed421d2e503b8d176fd0.tar.gz gnunet-f178ee5c79255d00eec5ed421d2e503b8d176fd0.zip |
-fixes, added get_authority api
Diffstat (limited to 'src/gns/plugin_block_gns.c')
-rw-r--r-- | src/gns/plugin_block_gns.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c index fd6fcc250..4c8ab3eb9 100644 --- a/src/gns/plugin_block_gns.c +++ b/src/gns/plugin_block_gns.c | |||
@@ -72,6 +72,7 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
72 | uint32_t rd_count; | 72 | uint32_t rd_count; |
73 | char* rd_data = NULL; | 73 | char* rd_data = NULL; |
74 | int rd_len; | 74 | int rd_len; |
75 | uint32_t record_xquery; | ||
75 | unsigned int record_match; | 76 | unsigned int record_match; |
76 | 77 | ||
77 | if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) | 78 | if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) |
@@ -102,7 +103,7 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
102 | { | 103 | { |
103 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; | 104 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; |
104 | unsigned int i; | 105 | unsigned int i; |
105 | uint32_t record_xquery = ntohl(*((uint32_t*)xquery)); | 106 | struct GNUNET_TIME_Absolute exp = GNUNET_TIME_absolute_get_forever(); |
106 | 107 | ||
107 | if (GNUNET_SYSERR == GNUNET_NAMESTORE_records_deserialize (rd_len, | 108 | if (GNUNET_SYSERR == GNUNET_NAMESTORE_records_deserialize (rd_len, |
108 | rd_data, | 109 | rd_data, |
@@ -113,18 +114,26 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
113 | "Data invalid (%d bytes, %d records)\n", rd_len, rd_count); | 114 | "Data invalid (%d bytes, %d records)\n", rd_len, rd_count); |
114 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; | 115 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; |
115 | } | 116 | } |
117 | |||
118 | if (xquery_size < sizeof(uint32_t)) | ||
119 | record_xquery = 0; | ||
120 | else | ||
121 | record_xquery = ntohl(*((uint32_t*)xquery)); | ||
116 | 122 | ||
117 | for (i=0; i<rd_count; i++) | 123 | for (i=0; i<rd_count; i++) |
118 | { | 124 | { |
119 | if (xquery_size < sizeof(uint32_t)) | ||
120 | continue; | ||
121 | 125 | ||
122 | if (rd[i].record_type == record_xquery) | 126 | exp = GNUNET_TIME_absolute_min (exp, rd[i].expiration); |
127 | |||
128 | if ((record_xquery != 0) | ||
129 | && (rd[i].record_type == record_xquery)) | ||
130 | { | ||
123 | record_match++; | 131 | record_match++; |
132 | } | ||
124 | } | 133 | } |
125 | 134 | ||
126 | if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key, | 135 | if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key, |
127 | GNUNET_TIME_absolute_get_forever(), | 136 | exp, |
128 | name, | 137 | name, |
129 | rd_count, | 138 | rd_count, |
130 | rd, | 139 | rd, |
@@ -136,7 +145,7 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
136 | } | 145 | } |
137 | 146 | ||
138 | //No record matches query | 147 | //No record matches query |
139 | if ((xquery_size > 0) && (record_match == 0)) | 148 | if ((record_xquery != 0) && (record_match == 0)) |
140 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | 149 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; |
141 | 150 | ||
142 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Records match\n"); | 151 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Records match\n"); |