gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r253 - in GNUnet/src/applications/fs: . ecrs lib module


From: grothoff
Subject: [GNUnet-SVN] r253 - in GNUnet/src/applications/fs: . ecrs lib module
Date: Sat, 12 Feb 2005 22:09:48 -0800 (PST)

Author: grothoff
Date: 2005-02-12 22:09:48 -0800 (Sat, 12 Feb 2005)
New Revision: 253

Modified:
   GNUnet/src/applications/fs/ecrs/download.c
   GNUnet/src/applications/fs/ecrs_core.c
   GNUnet/src/applications/fs/lib/fslib.c
   GNUnet/src/applications/fs/module/ondemand.c
Log:
bugfix

Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c  2005-02-13 05:06:30 UTC (rev 
252)
+++ GNUnet/src/applications/fs/ecrs/download.c  2005-02-13 06:09:48 UTC (rev 
253)
@@ -525,19 +525,21 @@
 static void delRequest(RequestManager * rm,
                       NodeClosure * node) {
   int i;
+  RequestEntry * re;
  
   MUTEX_LOCK(&rm->lock);
   for (i=0;i<rm->requestListIndex;i++) {
-    if (rm->requestList[i]->node == node) {
-      if (NULL != rm->requestList[i]->searchHandle)
-       FS_stop_search(rm->sctx,
-                      rm->requestList[i]->searchHandle);
-      FREE(rm->requestList[i]);
+    re = rm->requestList[i];
+    if (re->node == node) {
       rm->requestList[i] 
        = rm->requestList[--rm->requestListIndex];
       rm->requestList[rm->requestListIndex] 
        = NULL;
       MUTEX_UNLOCK(&rm->lock);
+      if (NULL != re->searchHandle)
+       FS_stop_search(rm->sctx,
+                      re->searchHandle);
+      FREE(re);
       return; 
     }
   }
@@ -816,13 +818,15 @@
   GNUNET_ASSERT(equalsHashCode160(query,
                                  &node->chk.query));
   size = ntohl(reply->size) - sizeof(Datastore_Value);
-  if (size != getNodeSize(node)) {
+  if ( (size <= sizeof(DBlock)) ||
+       (size - sizeof(DBlock) != getNodeSize(node)) ) {
     BREAK();
     return SYSERR; /* invalid size! */
   }
   /* request satisfied, stop requesting! */
   delRequest(node->ctx->rm,
             node);
+  size -= sizeof(DBlock);
   data = MALLOC(size);
   if (SYSERR == decryptContent((char*)&reply[1],
                               size,
@@ -852,7 +856,9 @@
     node->ctx->rm->abortFlag = YES;
     return SYSERR;
   }
-  updateProgress(node, data, size);
+  updateProgress(node, 
+                data, 
+                size);
   if (node->level > 0)
     iblock_download_children(node,
                             data,

Modified: GNUnet/src/applications/fs/ecrs_core.c
===================================================================
--- GNUnet/src/applications/fs/ecrs_core.c      2005-02-13 05:06:30 UTC (rev 
252)
+++ GNUnet/src/applications/fs/ecrs_core.c      2005-02-13 06:09:48 UTC (rev 
253)
@@ -54,14 +54,12 @@
 
   GNUNET_ASSERT(len > sizeof(DBlock));
   GNUNET_ASSERT((data!=NULL) && (query != NULL));
-  hash(data, len, &hc);
+  hash(&data[1], len - sizeof(DBlock), &hc);
   hashToKey(&hc,
            &skey,
            &iv[0]);
-  val = MALLOC(sizeof(Datastore_Value)
-              + len);
-  val->size = htonl(sizeof(Datastore_Value) + 
-                   len);
+  val = MALLOC(sizeof(Datastore_Value) + len);
+  val->size = htonl(sizeof(Datastore_Value) + len);
   val->type = htonl(D_BLOCK);
   val->prio = htonl(0);
   val->anonymityLevel = htonl(0);

Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c      2005-02-13 05:06:30 UTC (rev 
252)
+++ GNUnet/src/applications/fs/lib/fslib.c      2005-02-13 06:09:48 UTC (rev 
253)
@@ -118,7 +118,7 @@
 SEARCH_CONTEXT * FS_SEARCH_makeContext() {
   SEARCH_CONTEXT * ret;
   ret = MALLOC(sizeof(SEARCH_CONTEXT));
-  MUTEX_CREATE(&ret->lock);
+  MUTEX_CREATE_RECURSIVE(&ret->lock);
   ret->sock = getClientSocket();
   ret->handles = NULL;
   ret->handleCount = 0;

Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c        2005-02-13 05:06:30 UTC 
(rev 252)
+++ GNUnet/src/applications/fs/module/ondemand.c        2005-02-13 06:09:48 UTC 
(rev 253)
@@ -167,6 +167,20 @@
   fileBlockGetQuery(content,
                    size,
                    &key);  
+  /* extra check */
+  { 
+    Datastore_Value * dsvalue;
+    if (OK != fileBlockEncode(content,
+                             size,
+                             &key,
+                             &dsvalue)) {
+      BREAK();
+    } else {
+      FREE(dsvalue);
+    }
+  }
+  /* end extra check */
+
   IFLOG(LOG_DEBUG,
        hash2enc(&key, &enc));
   LOG(LOG_DEBUG,





reply via email to

[Prev in Thread] Current Thread [Next in Thread]