[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5217 - in GNUnet/src: applications/fs/module applications/
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5217 - in GNUnet/src: applications/fs/module applications/gap applications/sqstore_sqlite server util/network |
Date: |
Mon, 2 Jul 2007 00:45:12 -0600 (MDT) |
Author: grothoff
Date: 2007-07-02 00:45:12 -0600 (Mon, 02 Jul 2007)
New Revision: 5217
Modified:
GNUnet/src/applications/fs/module/fs.c
GNUnet/src/applications/gap/gap.c
GNUnet/src/applications/gap/gap.h
GNUnet/src/applications/sqstore_sqlite/sqlite.c
GNUnet/src/server/handler.c
GNUnet/src/util/network/select.c
Log:
stuff
Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c 2007-07-02 06:43:46 UTC (rev
5216)
+++ GNUnet/src/applications/fs/module/fs.c 2007-07-02 06:45:12 UTC (rev
5217)
@@ -165,11 +165,6 @@
EncName enc;
#endif
- dv = gapWrapperToDatastoreValue(value, prio);
- if (dv == NULL) {
- GE_BREAK(ectx, 0);
- return SYSERR;
- }
gw = (const GapWrapper*) value;
size = ntohl(gw->dc.size) - sizeof(GapWrapper);
if ( (OK != getQueryFor(size,
@@ -177,10 +172,14 @@
YES,
&hc)) ||
(! equalsHashCode512(&hc, query)) ) {
- GE_BREAK(ectx, 0); /* value failed verification! */
- FREE(dv);
+ GE_BREAK_OP(ectx, 0); /* value failed verification! */
return SYSERR;
}
+ dv = gapWrapperToDatastoreValue(value, prio);
+ if (dv == NULL) {
+ GE_BREAK_OP(ectx, 0);
+ return SYSERR;
+ }
if (YES != isDatumApplicable(ntohl(dv->type),
ntohl(dv->size) - sizeof(Datastore_Value),
(const DBlock*) &dv[1],
@@ -232,6 +231,9 @@
const DataContainer * value,
void * ctx) {
DHT_GET_CLS * cls = ctx;
+ const GapWrapper * gw;
+ unsigned int size;
+ HashCode512 hc;
#if DEBUG_FS
EncName enc;
@@ -244,6 +246,17 @@
"Found reply to query `%s'.\n",
&enc);
#endif
+ gw = (const GapWrapper*) value;
+ size = ntohl(gw->dc.size) - sizeof(GapWrapper);
+ if ( (OK != getQueryFor(size,
+ (const DBlock*) &gw[1],
+ YES,
+ &hc)) ||
+ (! equalsHashCode512(&hc, query)) ) {
+ GE_BREAK(NULL, 0);
+ return OK;
+ }
+
gapPut(NULL,
query,
value,
@@ -369,6 +382,7 @@
unsigned int size;
cron_t now;
cron_t et;
+ HashCode512 hc;
size = sizeof(GapWrapper) +
ntohs(ri->header.size) - sizeof(CS_fs_request_insert_MESSAGE);
@@ -389,11 +403,20 @@
memcpy(&gw[1],
&ri[1],
size - sizeof(GapWrapper));
- dht->put(&query,
- type,
- size,
- et,
- (const char*) gw);
+ /* sanity check */
+ if ( (OK != getQueryFor(size - sizeof(GapWrapper),
+ (const DBlock*) &gw[1],
+ YES,
+ &hc)) ||
+ (! equalsHashCode512(&hc, &query)) ) {
+ GE_BREAK(NULL, 0);
+ } else {
+ dht->put(&query,
+ type,
+ size,
+ et,
+ (const char*) gw);
+ }
FREE(gw);
}
FREE(datum);
@@ -706,6 +729,9 @@
Datastore_Value * xvalue;
unsigned int level;
EncName enc;
+#if EXTRA_CHECKS
+ HashCode512 hc;
+#endif
#if DEBUG_FS
IF_GELOG(ectx,
@@ -736,6 +762,16 @@
xvalue = NULL;
value = invalue;
}
+#if EXTRA_CHECKS
+ if ( (OK != getQueryFor(ntohl(value->size) - sizeof(Datastore_Value),
+ (const DBlock*) &value[1],
+ YES,
+ &hc)) ||
+ (! equalsHashCode512(&hc, key)) ) {
+ GE_BREAK(ectx, 0); /* value failed verification! */
+ return SYSERR;
+ }
+#endif
ret = isDatumApplicable(ntohl(value->type),
ntohl(value->size) - sizeof(Datastore_Value),
(const DBlock*) &value[1],
@@ -805,6 +841,7 @@
memcpy(&gw[1],
&value[1],
size - sizeof(GapWrapper));
+
if (ggc->resultCallback != NULL)
ret = ggc->resultCallback(key,
&gw->dc,
Modified: GNUnet/src/applications/gap/gap.c
===================================================================
--- GNUnet/src/applications/gap/gap.c 2007-07-02 06:43:46 UTC (rev 5216)
+++ GNUnet/src/applications/gap/gap.c 2007-07-02 06:45:12 UTC (rev 5217)
@@ -802,6 +802,33 @@
*/
static void useContentLater(void * data) {
MESSAGE_HEADER * pmsg = data;
+
+#if EXTRA_CHECKS
+ const P2P_gap_reply_MESSAGE * msg = data;
+ DataContainer * value;
+ unsigned int size;
+
+ if (ntohs(msg->header.size) < sizeof(P2P_gap_reply_MESSAGE)) {
+ GE_BREAK(NULL, 0);
+ FREE(pmsg);
+ return;
+ }
+ size = ntohs(msg->header.size) - sizeof(P2P_gap_reply_MESSAGE);
+ value = MALLOC(size + sizeof(DataContainer));
+ value->size = htonl(size + sizeof(DataContainer));
+ memcpy(&value[1],
+ &msg[1],
+ size);
+ if (SYSERR == bs->put(bs->closure,
+ &msg->primaryKey,
+ value,
+ 0)) {
+ GE_BREAK(NULL, 0);
+ FREE(pmsg);
+ return;
+ }
+#endif
+
useContent(NULL,
pmsg);
FREE(pmsg);
@@ -1360,6 +1387,7 @@
struct qLRC {
DataContainer ** values;
unsigned int valueCount;
+ HashCode512 query;
};
/**
@@ -1381,7 +1409,7 @@
struct qLRC * cls = closure;
int i;
-#if EXTRA_CHECKS
+#if EXTRA_CHECKS || 1
/* verify data is valid */
uri(value,
ANY_BLOCK,
@@ -1397,6 +1425,19 @@
cls->values[i],
ntohl(value->size)))
return OK; /* drop, duplicate entry in DB! */
+#if EXTRA_CHECKS
+ if ( (0 != memcmp(primaryKey,
+ &cls->query,
+ sizeof(HashCode512))) ||
+ (SYSERR == bs->put(bs->closure,
+ &cls->query,
+ value,
+ 0)) ) {
+ GE_BREAK(NULL, 0);
+ return OK;
+ }
+#endif
+
GROW(cls->values,
cls->valueCount,
cls->valueCount+1);
@@ -1502,6 +1543,7 @@
stats->change(stat_routing_processed, 1);
cls.values = NULL;
cls.valueCount = 0;
+ cls.query = query->queries[0];
if ( (isRouted == YES) && /* if we can't route, lookup useless! */
( (policy & QUERY_ANSWER) > 0) ) {
bs->get(bs->closure,
@@ -1529,6 +1571,25 @@
what we have */
for (i=0;i<cls.valueCount;i++) {
+ if ( (i == 0) &&
+ (SYSERR == bs->put(bs->closure,
+ &query->queries[0],
+ cls.values[perm[i]],
+ ite->priority)) ) {
+ GE_BREAK(NULL, 0);
+ FREE(cls.values[perm[i]]);
+ continue;
+ }
+#if EXTRA_CHECKS
+ if (SYSERR == bs->put(bs->closure,
+ &query->queries[0],
+ cls.values[perm[i]],
+ 0)) {
+ GE_BREAK(NULL, 0);
+ FREE(cls.values[perm[i]]);
+ continue;
+ }
+#endif
if ( (i < max) &&
(sender != NULL) &&
(YES == queueReply(sender,
@@ -1540,12 +1601,6 @@
(at least to give back results to local client &
to update priority; but only do this for
the first result */
- if (i == 0)
- bs->put(bs->closure,
- &query->queries[0],
- cls.values[perm[i]],
- ite->priority);
-
if (uri(cls.values[perm[i]],
ite->type,
NO, /* no need to verify local results! */
Modified: GNUnet/src/applications/gap/gap.h
===================================================================
--- GNUnet/src/applications/gap/gap.h 2007-07-02 06:43:46 UTC (rev 5216)
+++ GNUnet/src/applications/gap/gap.h 2007-07-02 06:45:12 UTC (rev 5217)
@@ -39,7 +39,8 @@
#define DEBUG_GAP NO
-#define EXTRA_CHECKS ALLOW_EXTRA_CHECKS
+#define EXTRA_CHECKS YES
+// ALLOW_EXTRA_CHECKS
/* ***************** policy constants **************** */
Modified: GNUnet/src/applications/sqstore_sqlite/sqlite.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlite.c 2007-07-02 06:43:46 UTC
(rev 5216)
+++ GNUnet/src/applications/sqstore_sqlite/sqlite.c 2007-07-02 06:45:12 UTC
(rev 5217)
@@ -38,6 +38,8 @@
#define DEBUG_SQLITE NO
+#define EXTRA_CHECKS YES
+
/**
* Die with an error message that indicates
* a failure of the command 'cmd' with the message given
@@ -351,6 +353,10 @@
/* benchmarking shows 2-12% overhead */
}
+#if EXTRA_CHECKS
+#include "ecrs_core.h"
+#endif
+
/**
* Given a full row from gn070 table
(size,type,prio,anonLevel,expire,hash,value),
* assemble it into a Datastore_Datum representation.
@@ -431,6 +437,24 @@
memcpy(&value[1],
sqlite3_column_blob(stmt, 6),
contentSize);
+#if EXTRA_CHECKS
+ if (ntohl(value->type) == D_BLOCK) {
+ HashCode512 hc;
+ DBlock * db;
+
+ db = (DBlock*) &value[1];
+ GE_BREAK(NULL,
+ ntohl(db->type) == D_BLOCK);
+ hash(&db[1],
+ contentSize - sizeof(DBlock),
+ &hc);
+ GE_BREAK(NULL,
+ 0 == memcmp(&hc,
+ &datum->key,
+ sizeof(HashCode512)));
+ }
+#endif
+
return datum;
}
@@ -1102,6 +1126,27 @@
GE_BREAK(ectx, 0);
return SYSERR;
}
+
+#if EXTRA_CHECKS
+ if (ntohl(value->type) == D_BLOCK) {
+ HashCode512 hc;
+ DBlock * db;
+
+ contentSize = ntohl(value->size)-sizeof(Datastore_Value);
+ db = (DBlock*) &value[1];
+ GE_BREAK(NULL,
+ ntohl(db->type) == D_BLOCK);
+ hash(&db[1],
+ contentSize - sizeof(DBlock),
+ &hc);
+ if (0 != memcmp(&hc,
+ key,
+ sizeof(HashCode512))) {
+ GE_BREAK(NULL, 0);
+ }
+ }
+#endif
+
dbh = getDBHandle();
if (db->lastSync > 1000)
syncStats(dbh);
Modified: GNUnet/src/server/handler.c
===================================================================
--- GNUnet/src/server/handler.c 2007-07-02 06:43:46 UTC (rev 5216)
+++ GNUnet/src/server/handler.c 2007-07-02 06:45:12 UTC (rev 5217)
@@ -627,6 +627,7 @@
}
/* check for blacklisting */
if (YES == identity->isBlacklistedStrict(&mp->sender)) {
+#if DEBUG_HANDLER
EncName enc;
IF_GELOG(ectx,
GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
@@ -636,6 +637,7 @@
GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
"Strictly blacklisted peer `%s' sent message, dropping for now.\n",
(char*)&enc);
+#endif
#if TRACK_DISCARD
MUTEX_LOCK(globalLock_);
blacklisted++;
Modified: GNUnet/src/util/network/select.c
===================================================================
--- GNUnet/src/util/network/select.c 2007-07-02 06:43:46 UTC (rev 5216)
+++ GNUnet/src/util/network/select.c 2007-07-02 06:45:12 UTC (rev 5217)
@@ -902,7 +902,7 @@
void select_destroy(struct SelectHandle * sh) {
void * unused;
-#if DEBUG_SELECT || 1
+#if DEBUG_SELECT
GE_LOG(sh->ectx,
GE_DEBUG | GE_DEVELOPER | GE_BULK,
"Destroying select %p\n",
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5217 - in GNUnet/src: applications/fs/module applications/gap applications/sqstore_sqlite server util/network,
gnunet <=