aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ats/gnunet-ats-solver-eval.c5
-rw-r--r--src/gnsrecord/gnsrecord_misc.c17
-rw-r--r--src/gnsrecord/gnunet-gnsrecord-tvg.c9
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_client.c6
-rw-r--r--src/identity/gnunet-service-identity.c3
-rw-r--r--src/include/gnunet_gnsrecord_lib.h12
-rw-r--r--src/include/gnunet_strings_lib.h14
-rw-r--r--src/util/crypto_hash.c3
-rw-r--r--src/util/strings.c43
-rw-r--r--src/util/test_strings.c7
10 files changed, 59 insertions, 60 deletions
diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c
index 25b963532..ba7994686 100644
--- a/src/ats/gnunet-ats-solver-eval.c
+++ b/src/ats/gnunet-ats-solver-eval.c
@@ -442,7 +442,7 @@ GNUNET_ATS_solver_logging_write_to_disk (struct LoggingHandle *l, int
442 } 442 }
443 } 443 }
444 444
445cleanup: 445 cleanup:
446 next = lf_head; 446 next = lf_head;
447 for (cur = next; NULL != cur; cur = next) 447 for (cur = next; NULL != cur; cur = next)
448 { 448 {
@@ -1414,7 +1414,8 @@ load_op_add_address (struct GNUNET_ATS_TEST_Operation *o,
1414 } 1414 }
1415 else 1415 else
1416 { 1416 {
1417 GNUNET_STRINGS_utf8_toupper (op_network, op_network); 1417 GNUNET_break (GNUNET_OK == GNUNET_STRINGS_utf8_toupper (op_network,
1418 op_network));
1418 if (0 == strcmp (op_network, "UNSPECIFIED")) 1419 if (0 == strcmp (op_network, "UNSPECIFIED"))
1419 { 1420 {
1420 o->address_network = GNUNET_NT_UNSPECIFIED; 1421 o->address_network = GNUNET_NT_UNSPECIFIED;
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c
index 9b5e47c4c..b63142d5a 100644
--- a/src/gnsrecord/gnsrecord_misc.c
+++ b/src/gnsrecord/gnsrecord_misc.c
@@ -38,23 +38,10 @@
38#define LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__) 38#define LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__)
39 39
40char * 40char *
41GNUNET_GNSRECORD_string_to_lowercase (const char *src)
42{
43 char *res;
44
45 res = GNUNET_strdup (src);
46 GNUNET_STRINGS_utf8_tolower (src, res);
47 return res;
48}
49
50char *
51GNUNET_GNSRECORD_string_normalize (const char *src) 41GNUNET_GNSRECORD_string_normalize (const char *src)
52{ 42{
53 char *res; 43 /*FIXME: We may want to follow RFC3491 a bit more (Nameprep)*/
54 res = GNUNET_strdup (src); 44 return GNUNET_STRINGS_utf8_normalize (src);
55 GNUNET_STRINGS_utf8_tolower (src, res);
56 GNUNET_STRINGS_utf8_normalize (src, res);
57 return res;
58} 45}
59 46
60/** 47/**
diff --git a/src/gnsrecord/gnunet-gnsrecord-tvg.c b/src/gnsrecord/gnunet-gnsrecord-tvg.c
index 4afa458f1..31a2c5da2 100644
--- a/src/gnsrecord/gnunet-gnsrecord-tvg.c
+++ b/src/gnsrecord/gnunet-gnsrecord-tvg.c
@@ -426,9 +426,14 @@ run (void *cls,
426 rd[2].flags = GNUNET_GNSRECORD_RF_SUPPLEMENTAL | GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 426 rd[2].flags = GNUNET_GNSRECORD_RF_SUPPLEMENTAL | GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
427 427
428 run_pkey (&rd_pkey, 1, "testdelegation"); 428 run_pkey (&rd_pkey, 1, "testdelegation");
429 run_pkey (rd, 3, "\u65b0 Name System"); 429 run_pkey (rd, 3, "namesystem");
430 run_edkey (&rd_pkey, 1, "testdelegation"); 430 run_edkey (&rd_pkey, 1, "testdelegation");
431 run_edkey (rd, 3, "\u65b0 Name System"); 431 run_edkey (rd, 3, "namesystem");
432 /*char *norm_lbl;
433 norm_lbl = GNUNET_GNSRECORD_string_normalize ("q\u0307\u0323namesysteM");
434 print_bytes ("q\u0307\u0323namesysteM", strlen ("q\u0307\u0323namesysteM"), 8);
435 print_bytes (norm_lbl, strlen (norm_lbl), 8);
436 printf ("%s\n", norm_lbl);*/
432} 437}
433 438
434 439
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c
index 44966d3de..1f7d4cc35 100644
--- a/src/hostlist/gnunet-daemon-hostlist_client.c
+++ b/src/hostlist/gnunet-daemon-hostlist_client.c
@@ -1635,7 +1635,11 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
1635 "PROXY_TYPE", 1635 "PROXY_TYPE",
1636 &proxytype_str)) 1636 &proxytype_str))
1637 { 1637 {
1638 GNUNET_STRINGS_utf8_toupper (proxytype_str, proxytype_str); 1638 if (GNUNET_OK != GNUNET_STRINGS_utf8_toupper (proxytype_str,
1639 proxytype_str))
1640 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1641 "Unable to convert `%s' to UTF-8 uppercase\n",
1642 proxytype_str);
1639 proxy_type = CURLPROXY_HTTP; 1643 proxy_type = CURLPROXY_HTTP;
1640 if (0 == strcmp (proxytype_str, "HTTP")) 1644 if (0 == strcmp (proxytype_str, "HTTP"))
1641 proxy_type = CURLPROXY_HTTP; 1645 proxy_type = CURLPROXY_HTTP;
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c
index 2bb4b0897..51f897557 100644
--- a/src/identity/gnunet-service-identity.c
+++ b/src/identity/gnunet-service-identity.c
@@ -489,8 +489,7 @@ handle_get_default_message (void *cls,
489 char *identifier; 489 char *identifier;
490 490
491 name = GNUNET_strdup ((const char *) &gdm[1]); 491 name = GNUNET_strdup ((const char *) &gdm[1]);
492 GNUNET_STRINGS_utf8_tolower ((const char *) &gdm[1], 492 GNUNET_STRINGS_utf8_tolower ((const char *) &gdm[1], name);
493 name);
494 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 493 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
495 "Received GET_DEFAULT for service `%s' from client\n", 494 "Received GET_DEFAULT for service `%s' from client\n",
496 name); 495 name);
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h
index cbf7ee15c..590d83476 100644
--- a/src/include/gnunet_gnsrecord_lib.h
+++ b/src/include/gnunet_gnsrecord_lib.h
@@ -431,7 +431,8 @@ GNUNET_GNSRECORD_is_expired (const struct GNUNET_GNSRECORD_Data *rd);
431 431
432 432
433/** 433/**
434 * Normalize a UTF-8 string to UTF-8 NFC 434 * Normalize a UTF-8 string to a GNS name
435 *
435 * @param src source string 436 * @param src source string
436 * @return converted result 437 * @return converted result
437 */ 438 */
@@ -440,15 +441,6 @@ GNUNET_GNSRECORD_string_normalize (const char *src);
440 441
441 442
442/** 443/**
443 * Convert a UTF-8 string to UTF-8 lowercase
444 * @param src source string
445 * @return converted result
446 */
447char *
448GNUNET_GNSRECORD_string_to_lowercase (const char *src);
449
450
451/**
452 * Convert a zone to a string (for printing debug messages). 444 * Convert a zone to a string (for printing debug messages).
453 * This is one of the very few calls in the entire API that is 445 * This is one of the very few calls in the entire API that is
454 * NOT reentrant! 446 * NOT reentrant!
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h
index 9dd2f733e..09c547b09 100644
--- a/src/include/gnunet_strings_lib.h
+++ b/src/include/gnunet_strings_lib.h
@@ -159,14 +159,12 @@ GNUNET_STRINGS_to_utf8 (const char *input,
159 159
160/** 160/**
161 * Normalize the utf-8 input string to NFC. 161 * Normalize the utf-8 input string to NFC.
162 * Output needs to be allocated appropriately.
163 * 162 *
164 * @param input input string 163 * @param input input string
165 * @param output output buffer 164 * @return result (freshly allocated) or NULL on error.
166 */ 165 */
167void 166char*
168GNUNET_STRINGS_utf8_normalize (const char *input, 167GNUNET_STRINGS_utf8_normalize (const char *input);
169 char *output);
170 168
171 169
172/** 170/**
@@ -192,8 +190,9 @@ GNUNET_STRINGS_from_utf8 (const char *input,
192 * 190 *
193 * @param input input string 191 * @param input input string
194 * @param output output buffer 192 * @param output output buffer
193 * @return GNUNET_OK on success
195 */ 194 */
196void 195enum GNUNET_GenericReturnValue
197GNUNET_STRINGS_utf8_tolower (const char *input, 196GNUNET_STRINGS_utf8_tolower (const char *input,
198 char *output); 197 char *output);
199 198
@@ -204,8 +203,9 @@ GNUNET_STRINGS_utf8_tolower (const char *input,
204 * 203 *
205 * @param input input string 204 * @param input input string
206 * @param output output buffer 205 * @param output output buffer
206 * @return GNUNET_OK on success
207 */ 207 */
208void 208enum GNUNET_GenericReturnValue
209GNUNET_STRINGS_utf8_toupper (const char *input, 209GNUNET_STRINGS_utf8_toupper (const char *input,
210 char *output); 210 char *output);
211 211
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c
index dcd46e5f9..f516f5474 100644
--- a/src/util/crypto_hash.c
+++ b/src/util/crypto_hash.c
@@ -76,7 +76,8 @@ GNUNET_CRYPTO_hash_from_string2 (const char *enc,
76 char upper_enc[enclen]; 76 char upper_enc[enclen];
77 char *up_ptr = upper_enc; 77 char *up_ptr = upper_enc;
78 78
79 GNUNET_STRINGS_utf8_toupper (enc, up_ptr); 79 if (GNUNET_OK != GNUNET_STRINGS_utf8_toupper (enc, up_ptr))
80 return GNUNET_SYSERR;
80 81
81 return GNUNET_STRINGS_string_to_data (upper_enc, enclen, 82 return GNUNET_STRINGS_string_to_data (upper_enc, enclen,
82 (unsigned char *) result, 83 (unsigned char *) result,
diff --git a/src/util/strings.c b/src/util/strings.c
index c63870e42..75e45ba6d 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -390,7 +390,7 @@ GNUNET_STRINGS_conv (const char *input,
390 ret[encoded_string_length] = '\0'; 390 ret[encoded_string_length] = '\0';
391 free (encoded_string); 391 free (encoded_string);
392 return ret; 392 return ret;
393fail: 393 fail:
394 LOG (GNUNET_ERROR_TYPE_WARNING, 394 LOG (GNUNET_ERROR_TYPE_WARNING,
395 _ ("Character sets requested were `%s'->`%s'\n"), 395 _ ("Character sets requested were `%s'->`%s'\n"),
396 "UTF-8", 396 "UTF-8",
@@ -426,24 +426,28 @@ GNUNET_STRINGS_from_utf8 (const char *input,
426} 426}
427 427
428 428
429void 429char *
430GNUNET_STRINGS_utf8_normalize (const char *input, 430GNUNET_STRINGS_utf8_normalize (const char *input)
431 char *output)
432{ 431{
433 uint8_t *tmp; 432 uint8_t *tmp;
434 size_t len; 433 size_t len;
435 434 char *output;
436 tmp = u8_normalize (UNINORM_NFKC, 435 tmp = u8_tolower ((uint8_t *) input,
437 (uint8_t *) input, 436 strlen ((char *) input),
438 strlen ((char*) input), 437 NULL,
439 NULL, 438 UNINORM_NFKC,
440 &len); 439 NULL,
440 &len);
441 if (NULL == tmp)
442 return NULL;
443 output = GNUNET_malloc (len + 1);
441 GNUNET_memcpy (output, tmp, len); 444 GNUNET_memcpy (output, tmp, len);
442 output[len] = '\0'; 445 output[len] = '\0';
443 free (tmp); 446 free (tmp);
447 return output;
444} 448}
445 449
446void 450enum GNUNET_GenericReturnValue
447GNUNET_STRINGS_utf8_tolower (const char *input, 451GNUNET_STRINGS_utf8_tolower (const char *input,
448 char *output) 452 char *output)
449{ 453{
@@ -456,13 +460,16 @@ GNUNET_STRINGS_utf8_tolower (const char *input,
456 UNINORM_NFD, 460 UNINORM_NFD,
457 NULL, 461 NULL,
458 &len); 462 &len);
463 if (NULL == tmp_in)
464 return GNUNET_SYSERR;
459 GNUNET_memcpy (output, tmp_in, len); 465 GNUNET_memcpy (output, tmp_in, len);
460 output[len] = '\0'; 466 output[len] = '\0';
461 free (tmp_in); 467 GNUNET_free (tmp_in);
468 return GNUNET_OK;
462} 469}
463 470
464 471
465void 472enum GNUNET_GenericReturnValue
466GNUNET_STRINGS_utf8_toupper (const char *input, 473GNUNET_STRINGS_utf8_toupper (const char *input,
467 char *output) 474 char *output)
468{ 475{
@@ -475,9 +482,13 @@ GNUNET_STRINGS_utf8_toupper (const char *input,
475 UNINORM_NFD, 482 UNINORM_NFD,
476 NULL, 483 NULL,
477 &len); 484 &len);
485 if (NULL == tmp_in)
486 return GNUNET_SYSERR;
487 /* 0-terminator does not fit */
478 GNUNET_memcpy (output, tmp_in, len); 488 GNUNET_memcpy (output, tmp_in, len);
479 output[len] = '\0'; 489 output[len] = '\0';
480 free (tmp_in); 490 GNUNET_free (tmp_in);
491 return GNUNET_OK;
481} 492}
482 493
483 494
@@ -1604,7 +1615,7 @@ GNUNET_STRINGS_base64_encode (const void *in,
1604 char *opt; 1615 char *opt;
1605 1616
1606 ret = 0; 1617 ret = 0;
1607 GNUNET_assert (len < SIZE_MAX / 4 * 3 ); 1618 GNUNET_assert (len < SIZE_MAX / 4 * 3);
1608 opt = GNUNET_malloc (2 + (len * 4 / 3) + 8); 1619 opt = GNUNET_malloc (2 + (len * 4 / 3) + 8);
1609 for (size_t i = 0; i < len; ++i) 1620 for (size_t i = 0; i < len; ++i)
1610 { 1621 {
@@ -1741,7 +1752,7 @@ GNUNET_STRINGS_base64_decode (const char *data,
1741 output[ret++] = c; 1752 output[ret++] = c;
1742 } 1753 }
1743 } 1754 }
1744END: 1755 END:
1745 *out = output; 1756 *out = output;
1746 return ret; 1757 return ret;
1747} 1758}
diff --git a/src/util/test_strings.c b/src/util/test_strings.c
index 1ecd31464..cccffcaf5 100644
--- a/src/util/test_strings.c
+++ b/src/util/test_strings.c
@@ -114,10 +114,9 @@ main (int argc, char *argv[])
114 /* Normalization */ 114 /* Normalization */
115 r = "q\u0307\u0323"; /* Non-canonical order */ 115 r = "q\u0307\u0323"; /* Non-canonical order */
116 116
117 GNUNET_STRINGS_utf8_normalize (r, 117 b = GNUNET_STRINGS_utf8_normalize (r);
118 buf); 118 GNUNET_assert (0 == strcmp ("q\u0323\u0307", b));
119 GNUNET_assert (0 == strcmp ("q\u0323\u0307", buf)); 119 GNUNET_free (b);
120
121 b = GNUNET_STRINGS_to_utf8 ("TEST", 4, "ASCII"); 120 b = GNUNET_STRINGS_to_utf8 ("TEST", 4, "ASCII");
122 WANT ("TEST", b); 121 WANT ("TEST", b);
123 122