diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-08 18:41:07 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-08 18:41:07 +0000 |
commit | 2168e300fae74c5da28a2f3f57d67b7705f038a2 (patch) | |
tree | 2fec4a8a42292f9feff2481c85db50df3638f94d /src/namestore | |
parent | d9e144b09a47db8e72cbf85390df298421451322 (diff) | |
download | gnunet-2168e300fae74c5da28a2f3f57d67b7705f038a2.tar.gz gnunet-2168e300fae74c5da28a2f3f57d67b7705f038a2.zip |
fixing #2992: do not use hash of pkey and then match against pkey, that will not work...
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 6 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_sqlite.c | 28 |
2 files changed, 20 insertions, 14 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index ef200a8f4..49315f6e0 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -509,7 +509,7 @@ handle_block_cache (void *cls, | |||
509 | * @param rd array of records | 509 | * @param rd array of records |
510 | */ | 510 | */ |
511 | static void | 511 | static void |
512 | send_lookup_response (struct GNUNET_SERVER_NotificationContext *nc, | 512 | send_lookup_response (struct GNUNET_SERVER_NotificationContext *nc, |
513 | struct GNUNET_SERVER_Client *client, | 513 | struct GNUNET_SERVER_Client *client, |
514 | uint32_t request_id, | 514 | uint32_t request_id, |
515 | const struct GNUNET_CRYPTO_EccPrivateKey *zone_key, | 515 | const struct GNUNET_CRYPTO_EccPrivateKey *zone_key, |
@@ -701,7 +701,7 @@ handle_record_store (void *cls, | |||
701 | { | 701 | { |
702 | res = GSN_database->store_records (GSN_database->cls, | 702 | res = GSN_database->store_records (GSN_database->cls, |
703 | &rp_msg->private_key, | 703 | &rp_msg->private_key, |
704 | conv_name, | 704 | conv_name, |
705 | rd_count, rd); | 705 | rd_count, rd); |
706 | if (GNUNET_OK == res) | 706 | if (GNUNET_OK == res) |
707 | { | 707 | { |
@@ -863,6 +863,8 @@ handle_zone_to_name (void *cls, | |||
863 | if (GNUNET_NO == ztn_ctx.success) | 863 | if (GNUNET_NO == ztn_ctx.success) |
864 | { | 864 | { |
865 | /* no result found, send empty response */ | 865 | /* no result found, send empty response */ |
866 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
867 | "Found no result for zone-to-name lookup.\n"); | ||
866 | memset (&ztnr_msg, 0, sizeof (ztnr_msg)); | 868 | memset (&ztnr_msg, 0, sizeof (ztnr_msg)); |
867 | ztnr_msg.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE); | 869 | ztnr_msg.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE); |
868 | ztnr_msg.gns_header.header.size = htons (sizeof (ztnr_msg)); | 870 | ztnr_msg.gns_header.header.size = htons (sizeof (ztnr_msg)); |
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c index 1acb5aff2..bd32e3fd1 100644 --- a/src/namestore/plugin_namestore_sqlite.c +++ b/src/namestore/plugin_namestore_sqlite.c | |||
@@ -158,7 +158,7 @@ create_indices (sqlite3 * dbh) | |||
158 | sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS ir_block_expiration ON ns096blocks (expiration_time)", | 158 | sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS ir_block_expiration ON ns096blocks (expiration_time)", |
159 | NULL, NULL, NULL)) || | 159 | NULL, NULL, NULL)) || |
160 | (SQLITE_OK != | 160 | (SQLITE_OK != |
161 | sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS ir_pkey_reverse ON ns096records (zone_private_key,pkey_hash)", | 161 | sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS ir_pkey_reverse ON ns096records (zone_private_key,pkey)", |
162 | NULL, NULL, NULL)) || | 162 | NULL, NULL, NULL)) || |
163 | (SQLITE_OK != | 163 | (SQLITE_OK != |
164 | sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS ir_pkey_iter ON ns096records (zone_private_key,rvalue)", | 164 | sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS ir_pkey_iter ON ns096records (zone_private_key,rvalue)", |
@@ -284,7 +284,7 @@ database_setup (struct Plugin *plugin) | |||
284 | (plugin->dbh, | 284 | (plugin->dbh, |
285 | "CREATE TABLE ns096records (" | 285 | "CREATE TABLE ns096records (" |
286 | " zone_private_key BLOB NOT NULL DEFAULT ''," | 286 | " zone_private_key BLOB NOT NULL DEFAULT ''," |
287 | " pkey_hash BLOB," | 287 | " pkey BLOB," |
288 | " rvalue INT8 NOT NULL DEFAULT ''," | 288 | " rvalue INT8 NOT NULL DEFAULT ''," |
289 | " record_count INT NOT NULL DEFAULT 0," | 289 | " record_count INT NOT NULL DEFAULT 0," |
290 | " record_data BLOB NOT NULL DEFAULT ''," | 290 | " record_data BLOB NOT NULL DEFAULT ''," |
@@ -318,7 +318,7 @@ database_setup (struct Plugin *plugin) | |||
318 | &plugin->lookup_block) != SQLITE_OK) || | 318 | &plugin->lookup_block) != SQLITE_OK) || |
319 | (sq_prepare | 319 | (sq_prepare |
320 | (plugin->dbh, | 320 | (plugin->dbh, |
321 | "INSERT INTO ns096records (zone_private_key, pkey_hash, rvalue, record_count, record_data, label)" | 321 | "INSERT INTO ns096records (zone_private_key, pkey, rvalue, record_count, record_data, label)" |
322 | " VALUES (?, ?, ?, ?, ?, ?)", | 322 | " VALUES (?, ?, ?, ?, ?, ?)", |
323 | &plugin->store_records) != SQLITE_OK) || | 323 | &plugin->store_records) != SQLITE_OK) || |
324 | (sq_prepare | 324 | (sq_prepare |
@@ -328,7 +328,7 @@ database_setup (struct Plugin *plugin) | |||
328 | (sq_prepare | 328 | (sq_prepare |
329 | (plugin->dbh, | 329 | (plugin->dbh, |
330 | "SELECT record_count,record_data,label" | 330 | "SELECT record_count,record_data,label" |
331 | " FROM ns096records WHERE zone_private_key=? AND pkey_hash=?", | 331 | " FROM ns096records WHERE zone_private_key=? AND pkey=?", |
332 | &plugin->zone_to_name) != SQLITE_OK) || | 332 | &plugin->zone_to_name) != SQLITE_OK) || |
333 | (sq_prepare | 333 | (sq_prepare |
334 | (plugin->dbh, | 334 | (plugin->dbh, |
@@ -663,19 +663,19 @@ namestore_sqlite_store_records (void *cls, | |||
663 | { | 663 | { |
664 | struct Plugin *plugin = cls; | 664 | struct Plugin *plugin = cls; |
665 | int n; | 665 | int n; |
666 | struct GNUNET_HashCode pkey_hash; | 666 | struct GNUNET_CRYPTO_EccPublicSignKey pkey; |
667 | uint64_t rvalue; | 667 | uint64_t rvalue; |
668 | size_t data_size; | 668 | size_t data_size; |
669 | unsigned int i; | 669 | unsigned int i; |
670 | 670 | ||
671 | memset (&pkey_hash, 0, sizeof (pkey_hash)); | 671 | memset (&pkey, 0, sizeof (pkey)); |
672 | for (i=0;i<rd_count;i++) | 672 | for (i=0;i<rd_count;i++) |
673 | if (GNUNET_NAMESTORE_TYPE_PKEY == rd[i].record_type) | 673 | if (GNUNET_NAMESTORE_TYPE_PKEY == rd[i].record_type) |
674 | { | 674 | { |
675 | GNUNET_break (sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) == rd[i].data_size); | 675 | GNUNET_break (sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) == rd[i].data_size); |
676 | GNUNET_CRYPTO_hash (rd[i].data, | 676 | memcpy (&pkey, |
677 | rd[i].data_size, | 677 | rd[i].data, |
678 | &pkey_hash); | 678 | rd[i].data_size); |
679 | break; | 679 | break; |
680 | } | 680 | } |
681 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); | 681 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); |
@@ -720,7 +720,7 @@ namestore_sqlite_store_records (void *cls, | |||
720 | if ((SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 1, | 720 | if ((SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 1, |
721 | zone_key, sizeof (struct GNUNET_CRYPTO_EccPrivateKey), SQLITE_STATIC)) || | 721 | zone_key, sizeof (struct GNUNET_CRYPTO_EccPrivateKey), SQLITE_STATIC)) || |
722 | (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 2, | 722 | (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 2, |
723 | &pkey_hash, sizeof (struct GNUNET_HashCode), SQLITE_STATIC)) || | 723 | &pkey, sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), SQLITE_STATIC)) || |
724 | (SQLITE_OK != sqlite3_bind_int64 (plugin->store_records, 3, rvalue)) || | 724 | (SQLITE_OK != sqlite3_bind_int64 (plugin->store_records, 3, rvalue)) || |
725 | (SQLITE_OK != sqlite3_bind_int (plugin->store_records, 4, rd_count)) || | 725 | (SQLITE_OK != sqlite3_bind_int (plugin->store_records, 4, rd_count)) || |
726 | (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 5, data, data_size, SQLITE_STATIC)) || | 726 | (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 5, data, data_size, SQLITE_STATIC)) || |
@@ -733,7 +733,7 @@ namestore_sqlite_store_records (void *cls, | |||
733 | LOG_SQLITE (plugin, | 733 | LOG_SQLITE (plugin, |
734 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 734 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
735 | "sqlite3_reset"); | 735 | "sqlite3_reset"); |
736 | return GNUNET_SYSERR; | 736 | return GNUNET_SYSERR; |
737 | } | 737 | } |
738 | n = sqlite3_step (plugin->store_records); | 738 | n = sqlite3_step (plugin->store_records); |
739 | if (SQLITE_OK != sqlite3_reset (plugin->store_records)) | 739 | if (SQLITE_OK != sqlite3_reset (plugin->store_records)) |
@@ -775,7 +775,7 @@ namestore_sqlite_store_records (void *cls, | |||
775 | */ | 775 | */ |
776 | static int | 776 | static int |
777 | get_record_and_call_iterator (struct Plugin *plugin, | 777 | get_record_and_call_iterator (struct Plugin *plugin, |
778 | sqlite3_stmt *stmt, | 778 | sqlite3_stmt *stmt, |
779 | const struct GNUNET_CRYPTO_EccPrivateKey *zone_key, | 779 | const struct GNUNET_CRYPTO_EccPrivateKey *zone_key, |
780 | GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) | 780 | GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) |
781 | { | 781 | { |
@@ -932,6 +932,10 @@ namestore_sqlite_zone_to_name (void *cls, | |||
932 | "sqlite3_reset"); | 932 | "sqlite3_reset"); |
933 | return GNUNET_SYSERR; | 933 | return GNUNET_SYSERR; |
934 | } | 934 | } |
935 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
936 | "Performing reverse lookup for `%s'\n", | ||
937 | GNUNET_NAMESTORE_z2s (value_zone)); | ||
938 | |||
935 | return get_record_and_call_iterator (plugin, stmt, zone, iter, iter_cls); | 939 | return get_record_and_call_iterator (plugin, stmt, zone, iter, iter_cls); |
936 | } | 940 | } |
937 | 941 | ||