plane hacking
[oweals/gnunet.git] / src / fs / fs_search.c
index 21fd7e8f1b797de51d41cbac875e5422072f9d6f..f077bdac3f4957078b0feebcb1ae3e77989ea068 100644 (file)
@@ -4,7 +4,7 @@
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -574,11 +574,15 @@ process_kblock (struct GNUNET_FS_SearchContext *sc,
     }
   /* decrypt */
   GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].key, &skey, &iv);
-  GNUNET_CRYPTO_aes_decrypt (&kb[1],
-                            size - sizeof (struct KBlock),
-                            &skey,
-                            &iv,
-                            pt);
+  if (-1 == GNUNET_CRYPTO_aes_decrypt (&kb[1],
+                                      size - sizeof (struct KBlock),
+                                      &skey,
+                                      &iv,
+                                      pt))
+    {
+      GNUNET_break (0);
+      return;
+    }
   /* parse */
   eos = memchr (pt, 0, sizeof (pt));
   if (NULL == eos)
@@ -654,11 +658,15 @@ process_nblock (struct GNUNET_FS_SearchContext *sc,
     }
   /* decrypt */
   GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].key, &skey, &iv);
-  GNUNET_CRYPTO_aes_decrypt (&nb[1],
-                            size - sizeof (struct NBlock),
-                            &skey,
-                            &iv,
-                            pt);
+  if (-1 == GNUNET_CRYPTO_aes_decrypt (&nb[1],
+                                      size - sizeof (struct NBlock),
+                                      &skey,
+                                      &iv,
+                                      pt))
+    {
+      GNUNET_break (0);
+      return;
+    }
   /* parse */
   eos = memchr (pt, 0, sizeof (pt));
   if (NULL == eos)
@@ -736,11 +744,15 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
                      strlen (identifier), 
                      &key);
   GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv);
-  GNUNET_CRYPTO_aes_decrypt (&sb[1],
-                            len,
-                            &skey,
-                            &iv,
-                            pt);
+  if (-1 == GNUNET_CRYPTO_aes_decrypt (&sb[1],
+                                      len,
+                                      &skey,
+                                      &iv,
+                                      pt))
+    {
+      GNUNET_break (0);
+      return;
+    }
   /* parse */
   off = GNUNET_STRINGS_buffer_tokenize (pt,
                                        len, 
@@ -802,7 +814,7 @@ process_result (struct GNUNET_FS_SearchContext *sc,
     }
   switch (type)
     {
-    case GNUNET_BLOCK_TYPE_KBLOCK:
+    case GNUNET_BLOCK_TYPE_FS_KBLOCK:
       if (! GNUNET_FS_uri_test_ksk (sc->uri))
        {
          GNUNET_break (0);
@@ -815,7 +827,7 @@ process_result (struct GNUNET_FS_SearchContext *sc,
        }
       process_kblock (sc, data, size);
       break;
-    case GNUNET_BLOCK_TYPE_SBLOCK:
+    case GNUNET_BLOCK_TYPE_FS_SBLOCK:
       if (! GNUNET_FS_uri_test_sks (sc->uri))
        {
          GNUNET_break (0);
@@ -828,7 +840,7 @@ process_result (struct GNUNET_FS_SearchContext *sc,
        }
       process_sblock (sc, data, size);
       break;
-    case GNUNET_BLOCK_TYPE_NBLOCK:
+    case GNUNET_BLOCK_TYPE_FS_NBLOCK:
       if (! GNUNET_FS_uri_test_ksk (sc->uri))
        {
          GNUNET_break (0);
@@ -842,9 +854,9 @@ process_result (struct GNUNET_FS_SearchContext *sc,
       process_nblock (sc, data, size);
       break;
     case GNUNET_BLOCK_TYPE_ANY:
-    case GNUNET_BLOCK_TYPE_DBLOCK:
-    case GNUNET_BLOCK_TYPE_ONDEMAND:
-    case GNUNET_BLOCK_TYPE_IBLOCK:
+    case GNUNET_BLOCK_TYPE_FS_DBLOCK:
+    case GNUNET_BLOCK_TYPE_FS_ONDEMAND:
+    case GNUNET_BLOCK_TYPE_FS_IBLOCK:
       GNUNET_break (0);
       break;
     default:
@@ -969,7 +981,7 @@ transmit_search_request (void *cls,
        sm->options = htonl (1);
       else
        sm->options = htonl (0);      
-      sm->type = htonl (GNUNET_BLOCK_TYPE_SBLOCK);
+      sm->type = htonl (GNUNET_BLOCK_TYPE_FS_SBLOCK);
       sm->anonymity_level = htonl (sc->anonymity);
       sm->target = sc->uri->data.sks.namespace;
       identifier = sc->uri->data.sks.identifier;
@@ -1412,6 +1424,9 @@ search_result_free (void *cls,
   if (NULL != sr->download)
     {
       sr->download->search = NULL;
+      sr->download->top = GNUNET_FS_make_top (sr->download->h,
+                                             &GNUNET_FS_download_signal_suspend_,
+                                             sr->download);
       if (NULL != sr->download->serialization)
        {
          GNUNET_FS_remove_sync_file_ (sc->h,