- fix connection.c
[oweals/gnunet.git] / src / regex / plugin_block_regex.c
index 681ade880a395fcfd2ffac198b47568dfc33947e..1db1d0d5e6245eff6f11bfdfc427089ca9c12260 100644 (file)
@@ -60,35 +60,37 @@ evaluate_block_regex (void *cls, enum GNUNET_BLOCK_Type type,
                       size_t reply_block_size)
 {
   if (NULL == reply_block)
-    {
-      if (0 != xquery_size)
-       {
-         const char *s;  
-         
-         s = (const char *) xquery;
-         if ('\0' != s[xquery_size - 1]) /* must be valid 0-terminated string */
-           {
-             GNUNET_break_op (0);
-             return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
-           }
-       }
-      return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
-    }
+  {
+    if (0 != xquery_size)
+      {
+        const char *s;
+
+        s = (const char *) xquery;
+        if ('\0' != s[xquery_size - 1]) /* must be valid 0-terminated string */
+          {
+            GNUNET_break_op (0);
+            return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
+          }
+      }
+    return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
+  }
   if (0 != xquery_size)
   {
-    const char *query;
+    const char *s;
 
-    query = (const char *) xquery;
-    if ('\0' != query[xquery_size - 1]) /* must be valid 0-terminated string */
+    s = (const char *) xquery;
+    if ('\0' != s[xquery_size - 1]) /* must be valid 0-terminated string */
     {
       GNUNET_break_op (0);
       return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
     }
   }
-  else 
+  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);
     return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
   }
   switch (REGEX_BLOCK_check (reply_block,
@@ -172,7 +174,7 @@ evaluate_block_regex_accept (void *cls, enum GNUNET_BLOCK_Type type,
   if (ntohl (rba->purpose.size) !=
       sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
       sizeof (struct GNUNET_TIME_AbsoluteNBO) +
-      sizeof (struct GNUNET_HashCode)) 
+      sizeof (struct GNUNET_HashCode))
   {
     GNUNET_break_op(0);
     return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
@@ -182,12 +184,12 @@ evaluate_block_regex_accept (void *cls, enum GNUNET_BLOCK_Type type,
     /* technically invalid, but can happen without an error, so
        we're nice by reporting it as a 'duplicate' */
     return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
-  }  
+  }
   if (GNUNET_OK !=
-      GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT,
+      GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT,
                                &rba->purpose,
                                &rba->signature,
-                               &rba->public_key))
+                               &rba->peer.public_key))
   {
     GNUNET_break_op(0);
     return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;