diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-09-20 14:40:31 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-09-20 14:40:31 +0000 |
commit | 2009c8d07d00b2e731d1afe11ccb457017382985 (patch) | |
tree | bac05b8ff1f723079e3f90c4a4fae11c45775ee6 /src/regex | |
parent | 128d0a17bc0985be7e9d2c31449c2c0c3f8061da (diff) | |
download | gnunet-2009c8d07d00b2e731d1afe11ccb457017382985.tar.gz gnunet-2009c8d07d00b2e731d1afe11ccb457017382985.zip |
- fix block validation for DHT PUT requests
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/plugin_block_regex.c | 2 | ||||
-rw-r--r-- | src/regex/regex_block_lib.c | 20 | ||||
-rw-r--r-- | src/regex/regex_internal_dht.c | 3 |
3 files changed, 18 insertions, 7 deletions
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c index 5f3825f84..4dda893c9 100644 --- a/src/regex/plugin_block_regex.c +++ b/src/regex/plugin_block_regex.c | |||
@@ -87,7 +87,7 @@ evaluate_block_regex (void *cls, enum GNUNET_BLOCK_Type type, | |||
87 | } | 87 | } |
88 | else if (NULL != query) | 88 | else if (NULL != query) |
89 | { | 89 | { |
90 | /* xquery is required for regex, at least an empty string */ | 90 | /* xquery is required for regex GETs, at least an empty string */ |
91 | GNUNET_break_op (0); | 91 | GNUNET_break_op (0); |
92 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "type %d, query %p, xquery %p\n", | 92 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "type %d, query %p, xquery %p\n", |
93 | type, query, xquery); | 93 | type, query, xquery); |
diff --git a/src/regex/regex_block_lib.c b/src/regex/regex_block_lib.c index b352082cb..a2de3d4f8 100644 --- a/src/regex/regex_block_lib.c +++ b/src/regex/regex_block_lib.c | |||
@@ -211,6 +211,7 @@ REGEX_BLOCK_check (const struct RegexBlock *block, | |||
211 | struct CheckEdgeContext ctx; | 211 | struct CheckEdgeContext ctx; |
212 | int res; | 212 | int res; |
213 | 213 | ||
214 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Block check\n"); | ||
214 | if (GNUNET_OK != | 215 | if (GNUNET_OK != |
215 | REGEX_BLOCK_get_key (block, size, | 216 | REGEX_BLOCK_get_key (block, size, |
216 | &key)) | 217 | &key)) |
@@ -218,16 +219,22 @@ REGEX_BLOCK_check (const struct RegexBlock *block, | |||
218 | GNUNET_break_op (0); | 219 | GNUNET_break_op (0); |
219 | return GNUNET_SYSERR; | 220 | return GNUNET_SYSERR; |
220 | } | 221 | } |
221 | if (0 != memcmp (&key, | 222 | if (NULL != query && |
222 | query, | 223 | 0 != memcmp (&key, |
223 | sizeof (struct GNUNET_HashCode))) | 224 | query, |
225 | sizeof (struct GNUNET_HashCode))) | ||
224 | { | 226 | { |
225 | GNUNET_break_op (0); | 227 | GNUNET_break_op (0); |
226 | return GNUNET_SYSERR; | 228 | return GNUNET_SYSERR; |
227 | } | 229 | } |
228 | if ( (GNUNET_YES == ntohs (block->is_accepting)) && | 230 | if ( (GNUNET_YES == ntohs (block->is_accepting)) && |
229 | ( (NULL == xquery) || ('\0' == xquery[0]) ) ) | 231 | ( (NULL == xquery) || ('\0' == xquery[0]) ) ) |
232 | { | ||
233 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
234 | " out! Is accepting: %u, xquery %p\n", | ||
235 | ntohs(block->is_accepting), xquery); | ||
230 | return GNUNET_OK; | 236 | return GNUNET_OK; |
237 | } | ||
231 | ctx.xquery = xquery; | 238 | ctx.xquery = xquery; |
232 | ctx.found = GNUNET_NO; | 239 | ctx.found = GNUNET_NO; |
233 | res = REGEX_BLOCK_iterate (block, size, &check_edge, &ctx); | 240 | res = REGEX_BLOCK_iterate (block, size, &check_edge, &ctx); |
@@ -235,6 +242,7 @@ REGEX_BLOCK_check (const struct RegexBlock *block, | |||
235 | return GNUNET_SYSERR; | 242 | return GNUNET_SYSERR; |
236 | if (NULL == xquery) | 243 | if (NULL == xquery) |
237 | return GNUNET_YES; | 244 | return GNUNET_YES; |
245 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Result %d\n", ctx.found); | ||
238 | return ctx.found; | 246 | return ctx.found; |
239 | } | 247 | } |
240 | 248 | ||
@@ -312,6 +320,7 @@ REGEX_BLOCK_iterate (const struct RegexBlock *block, | |||
312 | unsigned int n; | 320 | unsigned int n; |
313 | size_t off; | 321 | size_t off; |
314 | 322 | ||
323 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Block iterate\n"); | ||
315 | if (size < sizeof (struct RegexBlock)) | 324 | if (size < sizeof (struct RegexBlock)) |
316 | { | 325 | { |
317 | GNUNET_break_op (0); | 326 | GNUNET_break_op (0); |
@@ -347,8 +356,9 @@ REGEX_BLOCK_iterate (const struct RegexBlock *block, | |||
347 | for (n=0;n<num_edges;n++) | 356 | for (n=0;n<num_edges;n++) |
348 | { | 357 | { |
349 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 358 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
350 | "Edge %u, off %u tokenlen %u\n", n, off, | 359 | " Edge %u/%u, off %u tokenlen %u (%.*s)\n", n+1, num_edges, off, |
351 | ntohs (edges[n].token_length)); | 360 | ntohs (edges[n].token_length), ntohs (edges[n].token_length), |
361 | &aux[off]); | ||
352 | if (NULL != iterator) | 362 | if (NULL != iterator) |
353 | if (GNUNET_NO == iterator (iter_cls, | 363 | if (GNUNET_NO == iterator (iter_cls, |
354 | &aux[off], | 364 | &aux[off], |
diff --git a/src/regex/regex_internal_dht.c b/src/regex/regex_internal_dht.c index 554d4320b..56477220b 100644 --- a/src/regex/regex_internal_dht.c +++ b/src/regex/regex_internal_dht.c | |||
@@ -595,11 +595,12 @@ regex_next_edge (const struct RegexBlock *block, | |||
595 | const char *rest; | 595 | const char *rest; |
596 | int result; | 596 | int result; |
597 | 597 | ||
598 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Next edge\n"); | ||
598 | /* Find the longest match for the current string position, | 599 | /* Find the longest match for the current string position, |
599 | * among tokens in the given block */ | 600 | * among tokens in the given block */ |
600 | ctx->longest_match = 0; | 601 | ctx->longest_match = 0; |
601 | result = REGEX_BLOCK_iterate (block, size, | 602 | result = REGEX_BLOCK_iterate (block, size, |
602 | ®ex_edge_iterator, ctx); | 603 | ®ex_edge_iterator, ctx); |
603 | GNUNET_break (GNUNET_OK == result); | 604 | GNUNET_break (GNUNET_OK == result); |
604 | 605 | ||
605 | /* Did anything match? */ | 606 | /* Did anything match? */ |