[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20759 - gnunet/src/gns
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20759 - gnunet/src/gns |
Date: |
Mon, 26 Mar 2012 01:03:09 +0200 |
Author: schanzen
Date: 2012-03-26 01:03:09 +0200 (Mon, 26 Mar 2012)
New Revision: 20759
Modified:
gnunet/src/gns/gnunet-service-gns.c
gnunet/src/gns/gnunet-service-gns_resolver.c
Log:
-normalize input names. important for DHT queries
Modified: gnunet/src/gns/gnunet-service-gns.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns.c 2012-03-25 21:56:39 UTC (rev 20758)
+++ gnunet/src/gns/gnunet-service-gns.c 2012-03-25 23:03:09 UTC (rev 20759)
@@ -31,6 +31,7 @@
#include "gnunet_dnsparser_lib.h"
#include "gnunet_dht_service.h"
#include "gnunet_namestore_service.h"
+#include <unicase.h>
#include "gnunet_gns_service.h"
#include "block_gns.h"
#include "gns.h"
@@ -155,6 +156,25 @@
static struct GNUNET_TIME_Relative default_lookup_timeout;
/**
+ * Normalizes the name in old
+ *
+ * @param old the old name to normalize
+ * @param new the buffer to write the new name to
+ */
+static void
+normalize_name(const char* old, char** new)
+{
+ uint8_t *tmp_name;
+ size_t n_len;
+
+ tmp_name = u8_tolower ((uint8_t*)old, strlen ((char *) old),
+ NULL, UNINORM_NFD, NULL, &n_len);
+
+ memcpy(*new, tmp_name, n_len);
+ (*new)[n_len] = '\0';
+ free(tmp_name);
+}
+/**
* Continue shutdown
*/
static void
@@ -448,7 +468,7 @@
size_t msg_size = 0;
struct ClientShortenHandle *csh;
- const char* name;
+ char name[MAX_DNS_NAME_LENGTH];
if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientShortenMessage))
{
@@ -475,7 +495,7 @@
csh->client = client;
csh->unique_id = sh_msg->id;
- name = (char*)&sh_msg[1];
+ normalize_name((char*)&sh_msg[1], (char**)&name);
if (strlen (name) < strlen(GNUNET_GNS_TLD)) {
csh->name = NULL;
@@ -563,7 +583,7 @@
size_t msg_size = 0;
struct ClientGetAuthHandle *cah;
- const char* name;
+ char name[MAX_DNS_NAME_LENGTH];
if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientGetAuthMessage))
{
@@ -586,8 +606,9 @@
return;
}
- name = (char*)&sh_msg[1];
+ normalize_name((char*)&sh_msg[1], (char**)&name);
+
cah = GNUNET_malloc(sizeof(struct ClientGetAuthHandle));
cah->client = client;
cah->unique_id = sh_msg->id;
@@ -690,7 +711,7 @@
size_t msg_size = 0;
size_t namelen;
- char* name;
+ char name[MAX_DNS_NAME_LENGTH];
struct ClientLookupHandle *clh;
if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientLookupMessage))
@@ -714,7 +735,7 @@
return;
}
- name = (char*)&sh_msg[1];
+ normalize_name((char*)&sh_msg[1], (char**)&name);
namelen = strlen(name)+1;
clh = GNUNET_malloc(sizeof(struct ClientLookupHandle));
clh->client = client;
Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c 2012-03-25 21:56:39 UTC
(rev 20758)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c 2012-03-25 23:03:09 UTC
(rev 20759)
@@ -1993,9 +1993,11 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"ZKEY is %s!\n", string_hash);
- normalized_zkey = u8_toupper ((uint8_t*)string_hash, strlen ((char *)
string_hash),
- NULL, UNINORM_NFD, NULL, &normal_len);
+ normalized_zkey = u8_toupper ((uint8_t*)string_hash,
+ strlen ((char *) string_hash),
+ NULL, UNINORM_NFD, NULL, &normal_len);
+
memcpy(nzkey, normalized_zkey, normal_len);
nzkey[normal_len] = '\0';
free(normalized_zkey);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20759 - gnunet/src/gns,
gnunet <=