From 2009c8d07d00b2e731d1afe11ccb457017382985 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Fri, 20 Sep 2013 14:40:31 +0000 Subject: - fix block validation for DHT PUT requests --- src/regex/plugin_block_regex.c | 2 +- src/regex/regex_block_lib.c | 20 +++++++++++++++----- 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, } else if (NULL != query) { - /* xquery is required for regex, at least an empty string */ + /* xquery is required for regex GETs, at least an empty string */ GNUNET_break_op (0); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "type %d, query %p, xquery %p\n", 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, struct CheckEdgeContext ctx; int res; + LOG (GNUNET_ERROR_TYPE_DEBUG, "Block check\n"); if (GNUNET_OK != REGEX_BLOCK_get_key (block, size, &key)) @@ -218,16 +219,22 @@ REGEX_BLOCK_check (const struct RegexBlock *block, GNUNET_break_op (0); return GNUNET_SYSERR; } - if (0 != memcmp (&key, - query, - sizeof (struct GNUNET_HashCode))) + if (NULL != query && + 0 != memcmp (&key, + query, + sizeof (struct GNUNET_HashCode))) { GNUNET_break_op (0); return GNUNET_SYSERR; } if ( (GNUNET_YES == ntohs (block->is_accepting)) && ( (NULL == xquery) || ('\0' == xquery[0]) ) ) + { + LOG (GNUNET_ERROR_TYPE_DEBUG, + " out! Is accepting: %u, xquery %p\n", + ntohs(block->is_accepting), xquery); return GNUNET_OK; + } ctx.xquery = xquery; ctx.found = GNUNET_NO; res = REGEX_BLOCK_iterate (block, size, &check_edge, &ctx); @@ -235,6 +242,7 @@ REGEX_BLOCK_check (const struct RegexBlock *block, return GNUNET_SYSERR; if (NULL == xquery) return GNUNET_YES; + LOG (GNUNET_ERROR_TYPE_DEBUG, "Result %d\n", ctx.found); return ctx.found; } @@ -312,6 +320,7 @@ REGEX_BLOCK_iterate (const struct RegexBlock *block, unsigned int n; size_t off; + LOG (GNUNET_ERROR_TYPE_DEBUG, "Block iterate\n"); if (size < sizeof (struct RegexBlock)) { GNUNET_break_op (0); @@ -347,8 +356,9 @@ REGEX_BLOCK_iterate (const struct RegexBlock *block, for (n=0;nlongest_match = 0; result = REGEX_BLOCK_iterate (block, size, - ®ex_edge_iterator, ctx); + ®ex_edge_iterator, ctx); GNUNET_break (GNUNET_OK == result); /* Did anything match? */ -- cgit v1.2.3