[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24985 - gnunet/src/namestore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24985 - gnunet/src/namestore |
Date: |
Thu, 15 Nov 2012 15:50:56 +0100 |
Author: wachs
Date: 2012-11-15 15:50:56 +0100 (Thu, 15 Nov 2012)
New Revision: 24985
Modified:
gnunet/src/namestore/gnunet-service-namestore.c
gnunet/src/namestore/namestore.h
gnunet/src/namestore/namestore_common.c
gnunet/src/namestore/test_namestore_api.conf
gnunet/src/namestore/test_namestore_api_create.c
gnunet/src/namestore/test_namestore_api_create_update.c
gnunet/src/namestore/test_namestore_api_lookup.c
gnunet/src/namestore/test_namestore_api_lookup_specific_type.c
gnunet/src/namestore/test_namestore_api_put.c
gnunet/src/namestore/test_namestore_api_remove.c
gnunet/src/namestore/test_namestore_api_remove_not_existing_record.c
gnunet/src/namestore/test_namestore_api_sign_verify.c
Log:
implementing mantis 0002193
Modified: gnunet/src/namestore/gnunet-service-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-service-namestore.c 2012-11-15 13:59:23 UTC
(rev 24984)
+++ gnunet/src/namestore/gnunet-service-namestore.c 2012-11-15 14:50:56 UTC
(rev 24985)
@@ -211,7 +211,6 @@
};
-
/**
* Writes the encrypted private key of a zone in a file
*
@@ -794,6 +793,7 @@
const char *name;
uint32_t rid;
uint32_t type;
+ char *conv_name;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' message\n",
@@ -838,15 +838,23 @@
type, name,
GNUNET_short_h2s(&ln_msg->zone));
+ conv_name = GNUNET_NAMESTORE_normalize_string (name);
+ if (NULL == conv_name)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Error converting name `%s'\n", name);
+ return;
+ }
+
/* do the actual lookup */
lnc.request_id = rid;
lnc.nc = nc;
lnc.record_type = type;
- lnc.name = name;
+ lnc.name = conv_name;
lnc.zone = &ln_msg->zone;
if (GNUNET_SYSERR ==
GSN_database->iterate_records (GSN_database->cls,
- &ln_msg->zone, name, 0 /* offset */,
+ &ln_msg->zone, conv_name, 0 /* offset */,
&handle_lookup_name_it, &lnc))
{
/* internal error (in database plugin); might be best to just hang up on
@@ -854,8 +862,10 @@
might also be false... */
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ GNUNET_free (conv_name);
return;
}
+ GNUNET_free (conv_name);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -883,6 +893,7 @@
size_t msg_size_exp;
const char *name;
const char *rd_ser;
+ char * conv_name;
uint32_t rid;
uint32_t rd_ser_len;
uint32_t rd_count;
@@ -932,37 +943,45 @@
expire = GNUNET_TIME_absolute_ntoh (rp_msg->expire);
signature = &rp_msg->signature;
rd_ser = &name[name_len];
+ struct GNUNET_NAMESTORE_RecordData rd[rd_count];
+
+ if (GNUNET_OK !=
+ GNUNET_NAMESTORE_records_deserialize (rd_ser_len, rd_ser, rd_count, rd))
{
- struct GNUNET_NAMESTORE_RecordData rd[rd_count];
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ GNUNET_CRYPTO_short_hash (&rp_msg->public_key,
+ sizeof (rp_msg->public_key),
+ &zone_hash);
- if (GNUNET_OK !=
- GNUNET_NAMESTORE_records_deserialize (rd_ser_len, rd_ser, rd_count, rd))
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ conv_name = GNUNET_NAMESTORE_normalize_string (name);
+ if (NULL == conv_name)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Error converting name `%s'\n", name);
return;
- }
- GNUNET_CRYPTO_short_hash (&rp_msg->public_key,
- sizeof (rp_msg->public_key),
- &zone_hash);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Putting %u records under name `%s' in zone `%s'\n",
- rd_count, name,
- GNUNET_short_h2s (&zone_hash));
- res = GSN_database->put_records(GSN_database->cls,
- &rp_msg->public_key,
- expire,
- name,
- rd_count, rd,
- signature);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Putting record for name `%s': %s\n",
- name,
- (GNUNET_OK == res) ? "OK" : "FAILED");
}
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Putting %u records under name `%s' in zone `%s'\n",
+ rd_count, conv_name,
+ GNUNET_short_h2s (&zone_hash));
+ res = GSN_database->put_records(GSN_database->cls,
+ &rp_msg->public_key,
+ expire,
+ conv_name,
+ rd_count, rd,
+ signature);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Putting record for name `%s': %s\n",
+ conv_name,
+ (GNUNET_OK == res) ? "OK" : "FAILED");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending `%s' message\n",
"RECORD_PUT_RESPONSE");
+ GNUNET_free (conv_name);
rpr_msg.gns_header.header.type = htons
(GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE);
rpr_msg.gns_header.header.size = htons (sizeof (struct
RecordPutResponseMessage));
rpr_msg.gns_header.r_id = htonl (rid);
@@ -1150,6 +1169,7 @@
uint32_t rid;
const char *pkey_tmp;
const char *name_tmp;
+ char *conv_name;
const char *rd_ser;
unsigned int rd_count;
int res;
@@ -1220,17 +1240,26 @@
sizeof (struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
&pubkey_hash);
learn_private_key (pkey);
+
+ conv_name = GNUNET_NAMESTORE_normalize_string(name_tmp);
+ if (NULL == conv_name)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Error converting name `%s'\n", name_tmp);
+ return;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Creating record for name `%s' in zone `%s'\n",
- name_tmp, GNUNET_short_h2s(&pubkey_hash));
+ conv_name, GNUNET_short_h2s(&pubkey_hash));
crc.expire = GNUNET_TIME_absolute_ntoh(rp_msg->expire);
crc.res = GNUNET_SYSERR;
crc.rd = &rd;
- crc.name = name_tmp;
+ crc.name = conv_name;
/* Get existing records for name */
- res = GSN_database->iterate_records (GSN_database->cls, &pubkey_hash,
name_tmp, 0,
+ res = GSN_database->iterate_records (GSN_database->cls, &pubkey_hash,
conv_name, 0,
&handle_create_record_it, &crc);
+ GNUNET_free (conv_name);
if (res != GNUNET_SYSERR)
res = GNUNET_OK;
@@ -1399,6 +1428,7 @@
const char *pkey_tmp;
const char *name_tmp;
const char *rd_ser;
+ char * conv_name;
size_t key_len;
size_t name_len;
size_t rd_ser_len;
@@ -1473,15 +1503,23 @@
return;
}
+ conv_name = GNUNET_NAMESTORE_normalize_string(name_tmp);
+ if (NULL == conv_name)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Error converting name `%s'\n", name_tmp);
+ return;
+ }
+
if (0 == rd_count)
{
/* remove the whole name and all records */
res = GSN_database->remove_records (GSN_database->cls,
&pubkey_hash,
- name_tmp);
+ conv_name);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Removing name `%s': %s\n",
- name_tmp, (GNUNET_OK == res) ? "OK" : "FAILED");
+ conv_name, (GNUNET_OK == res) ? "OK" : "FAILED");
if (GNUNET_OK != res)
/* Could not remove entry from database */
res = RECORD_REMOVE_RESULT_FAILED_TO_PUT_UPDATE;
@@ -1492,7 +1530,7 @@
{
/* remove a single record */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Removing record for name `%s' in zone `%s'\n", name_tmp,
+ "Removing record for name `%s' in zone `%s'\n", conv_name,
GNUNET_short_h2s (&pubkey_hash));
rrc.rd = &rd;
rrc.op_res = RECORD_REMOVE_RESULT_RECORD_NOT_FOUND;
@@ -1503,7 +1541,7 @@
{
res = GSN_database->iterate_records (GSN_database->cls,
&pubkey_hash,
- name_tmp,
+ conv_name,
off++,
&handle_record_remove_it, &rrc);
}
@@ -1527,6 +1565,7 @@
break;
}
}
+ GNUNET_free (conv_name);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending `%s' message\n",
"RECORD_REMOVE_RESPONSE");
Modified: gnunet/src/namestore/namestore.h
===================================================================
--- gnunet/src/namestore/namestore.h 2012-11-15 13:59:23 UTC (rev 24984)
+++ gnunet/src/namestore/namestore.h 2012-11-15 14:50:56 UTC (rev 24985)
@@ -32,6 +32,14 @@
#define MAX_NAME_LEN 256
/**
+ * Convert a string from to local codeset to UTF-8 lowercase
+ * @param src source string
+ * @return converted result
+ */
+char *
+GNUNET_NAMESTORE_normalize_string (const char *src);
+
+/**
* Convert a short hash to a string (for printing debug messages).
* This is one of the very few calls in the entire API that is
* NOT reentrant!
Modified: gnunet/src/namestore/namestore_common.c
===================================================================
--- gnunet/src/namestore/namestore_common.c 2012-11-15 13:59:23 UTC (rev
24984)
+++ gnunet/src/namestore/namestore_common.c 2012-11-15 14:50:56 UTC (rev
24985)
@@ -71,7 +71,26 @@
GNUNET_NETWORK_STRUCT_END
+/**
+ * Convert a string from to local codeset to UTF-8 lowercase
+ * @param src source string
+ * @return converted result
+ */
+char *
+GNUNET_NAMESTORE_normalize_string (const char *src)
+{
+ char *utf_8_str;
+ GNUNET_assert (NULL != src);
+ /* Convert to UTF8 */
+ utf_8_str = GNUNET_STRINGS_to_utf8 (src, strlen (src), nl_langinfo
(CODESET));
+ GNUNET_assert (NULL != utf_8_str);
+ /* normalize */
+ GNUNET_STRINGS_utf8_tolower(utf_8_str, &utf_8_str);
+ return utf_8_str;
+}
+
+
/**
* Convert a short hash to a string (for printing debug messages).
* This is one of the very few calls in the entire API that is
Modified: gnunet/src/namestore/test_namestore_api.conf
===================================================================
--- gnunet/src/namestore/test_namestore_api.conf 2012-11-15 13:59:23 UTC
(rev 24984)
+++ gnunet/src/namestore/test_namestore_api.conf 2012-11-15 14:50:56 UTC
(rev 24985)
@@ -4,7 +4,7 @@
UNIXPATH = /tmp/gnunet-p1-service-arm.sock
[namestore]
-#PREFIX = valgrind --leak-check=full --track-origins=yes
+#PREFIX = valgrind
AUTOSTART = YES
UNIXPATH = /tmp/gnunet-service-namestore.sock
UNIX_MATCH_UID = YES
@@ -12,7 +12,7 @@
PORT = 2099
HOSTNAME = localhost
HOME = $SERVICEHOME
-BINARY = gnunet-service-namestore
+BINARY = gnunet-service-namestore2
ACCEPT_FROM = 127.0.0.1;
ACCEPT_FROM6 = ::1;
DATABASE = sqlite
Modified: gnunet/src/namestore/test_namestore_api_create.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_create.c 2012-11-15 13:59:23 UTC
(rev 24984)
+++ gnunet/src/namestore/test_namestore_api_create.c 2012-11-15 14:50:56 UTC
(rev 24985)
@@ -84,6 +84,7 @@
if (privkey != NULL)
GNUNET_CRYPTO_rsa_key_free (privkey);
privkey = NULL;
+ GNUNET_free_non_null (s_name);
res = 1;
}
@@ -99,6 +100,7 @@
GNUNET_free ((void *) s_first_record->data);
GNUNET_free (s_first_record);
GNUNET_free_non_null (s_second_record);
+ GNUNET_free_non_null (s_name);
if (privkey != NULL)
GNUNET_CRYPTO_rsa_key_free (privkey);
privkey = NULL;
@@ -361,7 +363,7 @@
GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
/* create record */
- s_name = "dummy.dummy.gnunet";
+ s_name = GNUNET_NAMESTORE_normalize_string ("DUMMY.dummy.gnunet");
s_first_record = create_record (1);
rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, s_first_record);
Modified: gnunet/src/namestore/test_namestore_api_create_update.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_create_update.c 2012-11-15
13:59:23 UTC (rev 24984)
+++ gnunet/src/namestore/test_namestore_api_create_update.c 2012-11-15
14:50:56 UTC (rev 24985)
@@ -82,6 +82,7 @@
if (privkey != NULL)
GNUNET_CRYPTO_rsa_key_free (privkey);
privkey = NULL;
+ GNUNET_free_non_null (s_name);
res = 1;
}
@@ -103,6 +104,7 @@
if (nsh != NULL)
GNUNET_NAMESTORE_disconnect (nsh);
nsh = NULL;
+ GNUNET_free_non_null (s_name);
}
@@ -213,7 +215,7 @@
GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
/* create record */
- s_name = "dummy.dummy.gnunet";
+ s_name = GNUNET_NAMESTORE_normalize_string ("DUMMY.dummy.gnunet");
s_first_record = create_record (1);
rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, s_first_record);
Modified: gnunet/src/namestore/test_namestore_api_lookup.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_lookup.c 2012-11-15 13:59:23 UTC
(rev 24984)
+++ gnunet/src/namestore/test_namestore_api_lookup.c 2012-11-15 14:50:56 UTC
(rev 24985)
@@ -228,7 +228,7 @@
GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
/* create record */
- s_name = "dummy.dummy.gnunet";
+ s_name = GNUNET_NAMESTORE_normalize_string ("DUMMY.dummy.gnunet");
s_rd = create_record (RECORDS);
rd_ser_len = GNUNET_NAMESTORE_records_get_size(RECORDS, s_rd);
Modified: gnunet/src/namestore/test_namestore_api_lookup_specific_type.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_lookup_specific_type.c
2012-11-15 13:59:23 UTC (rev 24984)
+++ gnunet/src/namestore/test_namestore_api_lookup_specific_type.c
2012-11-15 14:50:56 UTC (rev 24985)
@@ -78,6 +78,7 @@
if (privkey != NULL)
GNUNET_CRYPTO_rsa_key_free (privkey);
privkey = NULL;
+ GNUNET_free_non_null (s_name);
res = 1;
}
@@ -97,7 +98,7 @@
GNUNET_free_non_null((void *) s_rd[c].data);
}
GNUNET_free (s_rd);
-
+ GNUNET_free_non_null (s_name);
if (privkey != NULL)
GNUNET_CRYPTO_rsa_key_free (privkey);
privkey = NULL;
@@ -286,7 +287,7 @@
GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
/* create record */
- s_name = "dummy.dummy.gnunet";
+ s_name = GNUNET_NAMESTORE_normalize_string ("DUMMY.dummy.gnunet");
s_rd = create_record (RECORDS);
rd_ser_len = GNUNET_NAMESTORE_records_get_size(RECORDS, s_rd);
Modified: gnunet/src/namestore/test_namestore_api_put.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_put.c 2012-11-15 13:59:23 UTC
(rev 24984)
+++ gnunet/src/namestore/test_namestore_api_put.c 2012-11-15 14:50:56 UTC
(rev 24985)
@@ -137,7 +137,7 @@
struct GNUNET_TESTING_Peer *peer)
{
struct GNUNET_CRYPTO_RsaSignature *signature;
- const char * s_name = "dummy.dummy.gnunet";
+ char * s_name;
int c;
char *hostkey_file;
struct GNUNET_TIME_Absolute et;
@@ -155,6 +155,7 @@
nsh = GNUNET_NAMESTORE_connect (cfg);
GNUNET_break (NULL != nsh);
/* create record */
+ s_name = GNUNET_NAMESTORE_normalize_string ("DUMMY.dummy.gnunet");
s_rd = create_record (RECORDS);
et.abs_value = s_rd[0].expiration_time;
signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_rd,
RECORDS);
@@ -167,6 +168,7 @@
for (c = 0; c < RECORDS; c++)
GNUNET_free_non_null((void *) s_rd[c].data);
GNUNET_free (s_rd);
+ GNUNET_free (s_name);
}
Modified: gnunet/src/namestore/test_namestore_api_remove.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_remove.c 2012-11-15 13:59:23 UTC
(rev 24984)
+++ gnunet/src/namestore/test_namestore_api_remove.c 2012-11-15 14:50:56 UTC
(rev 24985)
@@ -79,6 +79,7 @@
if (privkey != NULL)
GNUNET_CRYPTO_rsa_key_free (privkey);
privkey = NULL;
+ GNUNET_free_non_null (s_name);
res = 1;
}
@@ -102,6 +103,7 @@
if (nsh != NULL)
GNUNET_NAMESTORE_disconnect (nsh);
nsh = NULL;
+ GNUNET_free_non_null (s_name);
}
@@ -259,7 +261,7 @@
GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
/* create record */
- s_name = "dummy.dummy.gnunet";
+ s_name = GNUNET_NAMESTORE_normalize_string ("DUMMY.dummy.gnunet");
s_rd = create_record (RECORDS);
rd_ser_len = GNUNET_NAMESTORE_records_get_size(RECORDS, s_rd);
Modified: gnunet/src/namestore/test_namestore_api_remove_not_existing_record.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_remove_not_existing_record.c
2012-11-15 13:59:23 UTC (rev 24984)
+++ gnunet/src/namestore/test_namestore_api_remove_not_existing_record.c
2012-11-15 14:50:56 UTC (rev 24985)
@@ -79,6 +79,7 @@
if (privkey != NULL)
GNUNET_CRYPTO_rsa_key_free (privkey);
privkey = NULL;
+ GNUNET_free_non_null (s_name);
res = 1;
}
@@ -103,6 +104,7 @@
if (nsh != NULL)
GNUNET_NAMESTORE_disconnect (nsh);
nsh = NULL;
+ GNUNET_free_non_null (s_name);
}
@@ -195,7 +197,7 @@
GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
/* create record */
- s_name = "dummy.dummy.gnunet";
+ s_name = GNUNET_NAMESTORE_normalize_string ("DUMMY.dummy.gnunet");
s_rd = create_record (RECORDS);
rd_ser_len = GNUNET_NAMESTORE_records_get_size(RECORDS, s_rd);
Modified: gnunet/src/namestore/test_namestore_api_sign_verify.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_sign_verify.c 2012-11-15
13:59:23 UTC (rev 24984)
+++ gnunet/src/namestore/test_namestore_api_sign_verify.c 2012-11-15
14:50:56 UTC (rev 24985)
@@ -94,7 +94,7 @@
int res_w;
/* create record */
- s_name = "dummy.dummy.gnunet";
+ s_name = "DUMMY.dummy.gnunet";
s_rd = create_record (RECORDS);
signature = GNUNET_NAMESTORE_create_signature (privkey, expire, s_name,
s_rd, RECORDS);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24985 - gnunet/src/namestore,
gnunet <=