From: Martin Schanzenbach Date: Mon, 27 Feb 2012 09:22:41 +0000 (+0000) Subject: -fixes X-Git-Tag: initial-import-from-subversion-38251~14625 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ee21bffaa025a9408b37aec9c41a5594c5df668a;p=oweals%2Fgnunet.git -fixes --- diff --git a/src/gns/gns.conf.in b/src/gns/gns.conf.in index 3441583a9..422efdbb7 100644 --- a/src/gns/gns.conf.in +++ b/src/gns/gns.conf.in @@ -5,8 +5,9 @@ HOME = $SERVICEHOME CONFIG = $DEFAULTCONFIG BINARY = gnunet-service-gns UNIXPATH = /tmp/gnunet-service-gns.sock -ZONEKEY = $SERVICEHOME/zonekey -TRUSTED = bob:$SERVICEHOME/bobkey +ZONEKEY = /tmp/zonekey +TRUSTED = bob:/tmp/bobkey +HIJACK_DNS = YES OPTIONS = -L INFO # Access to this service can compromise all DNS queries in this diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 44de997e1..f89006513 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c @@ -215,8 +215,6 @@ process_authority_dht_result(void* cls, int i; GNUNET_HashCode zone, name_hash; - //FIXME GNS block check - if (data == NULL) return; @@ -229,7 +227,7 @@ process_authority_dht_result(void* cls, num_records = ntohl(nrb->rd_count); struct GNUNET_NAMESTORE_RecordData rd[num_records]; name = (char*)&nrb[1]; - rb = (struct GNSRecordBlock *)(&nrb[1] + strlen(name)); + rb = (struct GNSRecordBlock *)(&nrb[1] + strlen(name) + 1); for (i=0; iget_handle = GNUNET_DHT_get_start(dht_handle, timeout, GNUNET_BLOCK_TYPE_TEST, //FIXME todo &lookup_key, 5, //Replication level FIXME GNUNET_DHT_RO_NONE, - &rtype, //xquery FIXME this is bad + &xquery, //xquery FIXME is this bad? sizeof(GNUNET_GNS_RECORD_PKEY), &process_authority_dht_result, rh); @@ -354,7 +353,7 @@ process_name_dht_result(void* cls, struct GNUNET_NAMESTORE_RecordData rd[num_records]; name = (char*)&nrb[1]; - rb = (struct GNSRecordBlock*)(&nrb[1] + strlen(name)); + rb = (struct GNSRecordBlock*)(&nrb[1] + strlen(name) + 1); for (i=0; iquery->type); //FIXME how long to wait for results? rh->get_handle = GNUNET_DHT_get_start(dht_handle, timeout, GNUNET_BLOCK_TYPE_TEST, //FIXME todo &lookup_key, 5, //Replication level FIXME GNUNET_DHT_RO_NONE, - &rh->query->type, //xquery + &xquery, //xquery FIXME is this bad? sizeof(rh->query->type), &process_name_dht_result, rh); @@ -1055,7 +1056,7 @@ put_gns_record(void *cls, } rd_payload_length = rd_count * sizeof(struct GNSRecordBlock); - rd_payload_length += strlen(name) + sizeof(struct GNSNameRecordBlock); + rd_payload_length += strlen(name) + 1 + sizeof(struct GNSNameRecordBlock); //Calculate payload size for (i=0; ird_count = htonl(rd_count); - memcpy(&nrb[1], name, strlen(name)); //FIXME is this 0 terminated?? + memcpy(&nrb[1], name, strlen(name) + 1); //FIXME is this 0 terminated??-sure hope so for we use strlen - rb = (struct GNSRecordBlock *)(&nrb[1]+strlen(name)); + rb = (struct GNSRecordBlock *)(&nrb[1] + strlen(name) + 1); for (i=0; iflags); rd[i].data = (char*)&rb[1]; rb = &rb[1] + rd[i].data_size; + if (xquery_size > 0 && (rd[i].record_type == *((uint32_t*)xquery))) + record_match++; } + + //No record matches query + if (xquery_size > 0 && (record_match == 0)) + return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key, name, @@ -119,16 +128,23 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; } - //Cache FIXME we need a static function here to namestore? - /*GNUNET_NAMESTORE_record_put (handle, //FIXME where do i get this from? - &pkey_hash, - name, - expiration, //FIXME uh where do i get this from? - rd_count, - rd, - signature, - NULL, //cont - NULL); //cls*/ + //FIXME do bf check before or after crypto?? + if (NULL != bf) + { + GNUNET_CRYPTO_hash(reply_block, reply_block_size, &chash); + GNUNET_BLOCK_mingle_hash(&chash, bf_mutator, &mhash); + if (NULL != *bf) + { + if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test(*bf, &mhash)) + return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; + } + else + { + *bf = GNUNET_CONTAINER_bloomfilter_init(NULL, 8, BLOOMFILTER_K); + } + GNUNET_CONTAINER_bloomfilter_add(*bf, &mhash); + } + return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; }