diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-15 12:34:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-15 12:34:38 +0000 |
commit | 29b170354c0f50c7efe9ac01353db06dfeeea3f0 (patch) | |
tree | c39734317de9306f24abb9fa85488d66554f8b92 | |
parent | 17b458881260c7e80d4b5269c0ea816cfcb32407 (diff) | |
download | gnunet-29b170354c0f50c7efe9ac01353db06dfeeea3f0.tar.gz gnunet-29b170354c0f50c7efe9ac01353db06dfeeea3f0.zip |
-be more permissive with label syntax
-rw-r--r-- | src/dns/dnsparser.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/src/dns/dnsparser.c b/src/dns/dnsparser.c index 68b882279..45408909c 100644 --- a/src/dns/dnsparser.c +++ b/src/dns/dnsparser.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2010-2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -39,8 +39,8 @@ | |||
39 | * This can fail if the ASCII-conversion becomes longer than 63 characters. | 39 | * This can fail if the ASCII-conversion becomes longer than 63 characters. |
40 | * | 40 | * |
41 | * @param label label to check (UTF-8 string) | 41 | * @param label label to check (UTF-8 string) |
42 | * @return GNUNET_OK if the label can be converted to IDNA, | 42 | * @return #GNUNET_OK if the label can be converted to IDNA, |
43 | * GNUNET_SYSERR if the label is not valid for DNS names | 43 | * #GNUNET_SYSERR if the label is not valid for DNS names |
44 | */ | 44 | */ |
45 | int | 45 | int |
46 | GNUNET_DNSPARSER_check_label (const char *label) | 46 | GNUNET_DNSPARSER_check_label (const char *label) |
@@ -51,7 +51,7 @@ GNUNET_DNSPARSER_check_label (const char *label) | |||
51 | if (NULL != strchr (label, '.')) | 51 | if (NULL != strchr (label, '.')) |
52 | return GNUNET_SYSERR; /* not a label! Did you mean GNUNET_DNSPARSER_check_name? */ | 52 | return GNUNET_SYSERR; /* not a label! Did you mean GNUNET_DNSPARSER_check_name? */ |
53 | if (IDNA_SUCCESS != | 53 | if (IDNA_SUCCESS != |
54 | idna_to_ascii_8z (label, &output, IDNA_USE_STD3_ASCII_RULES)) | 54 | idna_to_ascii_8z (label, &output, IDNA_ALLOW_UNASSIGNED)) |
55 | return GNUNET_SYSERR; | 55 | return GNUNET_SYSERR; |
56 | slen = strlen (output); | 56 | slen = strlen (output); |
57 | #if WINDOWS | 57 | #if WINDOWS |
@@ -68,8 +68,8 @@ GNUNET_DNSPARSER_check_label (const char *label) | |||
68 | * This can fail if the ASCII-conversion becomes longer than 253 characters. | 68 | * This can fail if the ASCII-conversion becomes longer than 253 characters. |
69 | * | 69 | * |
70 | * @param name name to check (UTF-8 string) | 70 | * @param name name to check (UTF-8 string) |
71 | * @return GNUNET_OK if the label can be converted to IDNA, | 71 | * @return #GNUNET_OK if the label can be converted to IDNA, |
72 | * GNUNET_SYSERR if the label is not valid for DNS names | 72 | * #GNUNET_SYSERR if the label is not valid for DNS names |
73 | */ | 73 | */ |
74 | int | 74 | int |
75 | GNUNET_DNSPARSER_check_name (const char *name) | 75 | GNUNET_DNSPARSER_check_name (const char *name) |
@@ -89,7 +89,7 @@ GNUNET_DNSPARSER_check_name (const char *name) | |||
89 | } | 89 | } |
90 | GNUNET_free (ldup); | 90 | GNUNET_free (ldup); |
91 | if (IDNA_SUCCESS != | 91 | if (IDNA_SUCCESS != |
92 | idna_to_ascii_8z (name, &output, IDNA_USE_STD3_ASCII_RULES)) | 92 | idna_to_ascii_8z (name, &output, IDNA_ALLOW_UNASSIGNED)) |
93 | return GNUNET_SYSERR; | 93 | return GNUNET_SYSERR; |
94 | slen = strlen (output); | 94 | slen = strlen (output); |
95 | #if WINDOWS | 95 | #if WINDOWS |
@@ -105,7 +105,7 @@ GNUNET_DNSPARSER_check_name (const char *name) | |||
105 | * Parse name inside of a DNS query or record. | 105 | * Parse name inside of a DNS query or record. |
106 | * | 106 | * |
107 | * @param udp_payload entire UDP payload | 107 | * @param udp_payload entire UDP payload |
108 | * @param udp_payload_length length of udp_payload | 108 | * @param udp_payload_length length of @a udp_payload |
109 | * @param off pointer to the offset of the name to parse in the udp_payload (to be | 109 | * @param off pointer to the offset of the name to parse in the udp_payload (to be |
110 | * incremented by the size of the name) | 110 | * incremented by the size of the name) |
111 | * @param depth current depth of our recursion (to prevent stack overflow) | 111 | * @param depth current depth of our recursion (to prevent stack overflow) |
@@ -146,7 +146,7 @@ parse_name (const char *udp_payload, | |||
146 | (int) len, | 146 | (int) len, |
147 | &udp_payload[*off + 1]); | 147 | &udp_payload[*off + 1]); |
148 | if (IDNA_SUCCESS != | 148 | if (IDNA_SUCCESS != |
149 | (rc = idna_to_unicode_8z8z (tmp, &utf8, IDNA_USE_STD3_ASCII_RULES))) | 149 | (rc = idna_to_unicode_8z8z (tmp, &utf8, IDNA_ALLOW_UNASSIGNED))) |
150 | { | 150 | { |
151 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 151 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
152 | _("Failed to convert DNS IDNA name `%s' to UTF-8: %s\n"), | 152 | _("Failed to convert DNS IDNA name `%s' to UTF-8: %s\n"), |
@@ -222,11 +222,11 @@ parse_name (const char *udp_payload, | |||
222 | * Parse a DNS query entry. | 222 | * Parse a DNS query entry. |
223 | * | 223 | * |
224 | * @param udp_payload entire UDP payload | 224 | * @param udp_payload entire UDP payload |
225 | * @param udp_payload_length length of udp_payload | 225 | * @param udp_payload_length length of @a udp_payload |
226 | * @param off pointer to the offset of the query to parse in the udp_payload (to be | 226 | * @param off pointer to the offset of the query to parse in the udp_payload (to be |
227 | * incremented by the size of the query) | 227 | * incremented by the size of the query) |
228 | * @param q where to write the query information | 228 | * @param q where to write the query information |
229 | * @return GNUNET_OK on success, GNUNET_SYSERR if the query is malformed | 229 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the query is malformed |
230 | */ | 230 | */ |
231 | static int | 231 | static int |
232 | parse_query (const char *udp_payload, | 232 | parse_query (const char *udp_payload, |
@@ -257,11 +257,11 @@ parse_query (const char *udp_payload, | |||
257 | * Parse a DNS record entry. | 257 | * Parse a DNS record entry. |
258 | * | 258 | * |
259 | * @param udp_payload entire UDP payload | 259 | * @param udp_payload entire UDP payload |
260 | * @param udp_payload_length length of udp_payload | 260 | * @param udp_payload_length length of @a udp_payload |
261 | * @param off pointer to the offset of the record to parse in the udp_payload (to be | 261 | * @param off pointer to the offset of the record to parse in the udp_payload (to be |
262 | * incremented by the size of the record) | 262 | * incremented by the size of the record) |
263 | * @param r where to write the record information | 263 | * @param r where to write the record information |
264 | * @return GNUNET_OK on success, GNUNET_SYSERR if the record is malformed | 264 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the record is malformed |
265 | */ | 265 | */ |
266 | static int | 266 | static int |
267 | parse_record (const char *udp_payload, | 267 | parse_record (const char *udp_payload, |
@@ -406,7 +406,7 @@ parse_record (const char *udp_payload, | |||
406 | * processing and manipulation. | 406 | * processing and manipulation. |
407 | * | 407 | * |
408 | * @param udp_payload wire-format of the DNS packet | 408 | * @param udp_payload wire-format of the DNS packet |
409 | * @param udp_payload_length number of bytes in udp_payload | 409 | * @param udp_payload_length number of bytes in @a udp_payload |
410 | * @return NULL on error, otherwise the parsed packet | 410 | * @return NULL on error, otherwise the parsed packet |
411 | */ | 411 | */ |
412 | struct GNUNET_DNSPARSER_Packet * | 412 | struct GNUNET_DNSPARSER_Packet * |
@@ -423,7 +423,7 @@ GNUNET_DNSPARSER_parse (const char *udp_payload, | |||
423 | return NULL; | 423 | return NULL; |
424 | dns = (const struct GNUNET_TUN_DnsHeader *) udp_payload; | 424 | dns = (const struct GNUNET_TUN_DnsHeader *) udp_payload; |
425 | off = sizeof (struct GNUNET_TUN_DnsHeader); | 425 | off = sizeof (struct GNUNET_TUN_DnsHeader); |
426 | p = GNUNET_malloc (sizeof (struct GNUNET_DNSPARSER_Packet)); | 426 | p = GNUNET_new (struct GNUNET_DNSPARSER_Packet); |
427 | p->flags = dns->flags; | 427 | p->flags = dns->flags; |
428 | p->id = dns->id; | 428 | p->id = dns->id; |
429 | n = ntohs (dns->query_count); | 429 | n = ntohs (dns->query_count); |
@@ -594,13 +594,13 @@ GNUNET_DNSPARSER_free_packet (struct GNUNET_DNSPARSER_Packet *p) | |||
594 | * Add a DNS name to the UDP packet at the given location. | 594 | * Add a DNS name to the UDP packet at the given location. |
595 | * | 595 | * |
596 | * @param dst where to write the name | 596 | * @param dst where to write the name |
597 | * @param dst_len number of bytes in dst | 597 | * @param dst_len number of bytes in @a dst |
598 | * @param off pointer to offset where to write the name (increment by bytes used) | 598 | * @param off pointer to offset where to write the name (increment by bytes used) |
599 | * must not be changed if there is an error | 599 | * must not be changed if there is an error |
600 | * @param name name to write | 600 | * @param name name to write |
601 | * @return GNUNET_SYSERR if 'name' is invalid | 601 | * @return #GNUNET_SYSERR if @a name is invalid |
602 | * GNUNET_NO if 'name' did not fit | 602 | * #GNUNET_NO if @a name did not fit |
603 | * GNUNET_OK if 'name' was added to 'dst' | 603 | * #GNUNET_OK if @a name was added to 'dst' |
604 | */ | 604 | */ |
605 | static int | 605 | static int |
606 | add_name (char *dst, | 606 | add_name (char *dst, |
@@ -620,7 +620,7 @@ add_name (char *dst, | |||
620 | return GNUNET_SYSERR; | 620 | return GNUNET_SYSERR; |
621 | 621 | ||
622 | if (IDNA_SUCCESS != | 622 | if (IDNA_SUCCESS != |
623 | (rc = idna_to_ascii_8z (name, &idna_start, IDNA_USE_STD3_ASCII_RULES))) | 623 | (rc = idna_to_ascii_8z (name, &idna_start, IDNA_ALLOW_UNASSIGNED))) |
624 | { | 624 | { |
625 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 625 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
626 | _("Failed to convert UTF-8 name `%s' to DNS IDNA format: %s\n"), | 626 | _("Failed to convert UTF-8 name `%s' to DNS IDNA format: %s\n"), |
@@ -674,9 +674,9 @@ add_name (char *dst, | |||
674 | * @param off pointer to offset where to write the query (increment by bytes used) | 674 | * @param off pointer to offset where to write the query (increment by bytes used) |
675 | * must not be changed if there is an error | 675 | * must not be changed if there is an error |
676 | * @param query query to write | 676 | * @param query query to write |
677 | * @return GNUNET_SYSERR if 'query' is invalid | 677 | * @return #GNUNET_SYSERR if 'query' is invalid |
678 | * GNUNET_NO if 'query' did not fit | 678 | * #GNUNET_NO if 'query' did not fit |
679 | * GNUNET_OK if 'query' was added to 'dst' | 679 | * #GNUNET_OK if 'query' was added to @a dst |
680 | */ | 680 | */ |
681 | static int | 681 | static int |
682 | add_query (char *dst, | 682 | add_query (char *dst, |
@@ -706,9 +706,9 @@ add_query (char *dst, | |||
706 | * @param off pointer to offset where to write the mx information (increment by bytes used); | 706 | * @param off pointer to offset where to write the mx information (increment by bytes used); |
707 | * can also change if there was an error | 707 | * can also change if there was an error |
708 | * @param mx mx information to write | 708 | * @param mx mx information to write |
709 | * @return GNUNET_SYSERR if 'mx' is invalid | 709 | * @return #GNUNET_SYSERR if @a mx is invalid |
710 | * GNUNET_NO if 'mx' did not fit | 710 | * #GNUNET_NO if @a mx did not fit |
711 | * GNUNET_OK if 'mx' was added to 'dst' | 711 | * #GNUNET_OK if @a mx was added to @a dst |
712 | */ | 712 | */ |
713 | static int | 713 | static int |
714 | add_mx (char *dst, | 714 | add_mx (char *dst, |
@@ -735,9 +735,9 @@ add_mx (char *dst, | |||
735 | * @param off pointer to offset where to write the SOA information (increment by bytes used) | 735 | * @param off pointer to offset where to write the SOA information (increment by bytes used) |
736 | * can also change if there was an error | 736 | * can also change if there was an error |
737 | * @param soa SOA information to write | 737 | * @param soa SOA information to write |
738 | * @return GNUNET_SYSERR if 'soa' is invalid | 738 | * @return #GNUNET_SYSERR if @a soa is invalid |
739 | * GNUNET_NO if 'soa' did not fit | 739 | * #GNUNET_NO if @a soa did not fit |
740 | * GNUNET_OK if 'soa' was added to 'dst' | 740 | * #GNUNET_OK if @a soa was added to 'dst' |
741 | */ | 741 | */ |
742 | static int | 742 | static int |
743 | add_soa (char *dst, | 743 | add_soa (char *dst, |
@@ -778,9 +778,9 @@ add_soa (char *dst, | |||
778 | * @param off pointer to offset where to write the SRV information (increment by bytes used) | 778 | * @param off pointer to offset where to write the SRV information (increment by bytes used) |
779 | * can also change if there was an error | 779 | * can also change if there was an error |
780 | * @param srv SRV information to write | 780 | * @param srv SRV information to write |
781 | * @return GNUNET_SYSERR if 'srv' is invalid | 781 | * @return #GNUNET_SYSERR if @a srv is invalid |
782 | * GNUNET_NO if 'srv' did not fit | 782 | * #GNUNET_NO if @a srv did not fit |
783 | * GNUNET_OK if 'srv' was added to 'dst' | 783 | * #GNUNET_OK if @a srv was added to 'dst' |
784 | */ | 784 | */ |
785 | static int | 785 | static int |
786 | add_srv (char *dst, | 786 | add_srv (char *dst, |
@@ -815,9 +815,9 @@ add_srv (char *dst, | |||
815 | * @param off pointer to offset where to write the query (increment by bytes used) | 815 | * @param off pointer to offset where to write the query (increment by bytes used) |
816 | * must not be changed if there is an error | 816 | * must not be changed if there is an error |
817 | * @param record record to write | 817 | * @param record record to write |
818 | * @return GNUNET_SYSERR if 'record' is invalid | 818 | * @return #GNUNET_SYSERR if 'record' is invalid |
819 | * GNUNET_NO if 'record' did not fit | 819 | * #GNUNET_NO if 'record' did not fit |
820 | * GNUNET_OK if 'record' was added to 'dst' | 820 | * #GNUNET_OK if 'record' was added to @a dst |
821 | */ | 821 | */ |
822 | static int | 822 | static int |
823 | add_record (char *dst, | 823 | add_record (char *dst, |
@@ -908,10 +908,10 @@ add_record (char *dst, | |||
908 | * @param p packet to pack | 908 | * @param p packet to pack |
909 | * @param max maximum allowed size for the resulting UDP payload | 909 | * @param max maximum allowed size for the resulting UDP payload |
910 | * @param buf set to a buffer with the packed message | 910 | * @param buf set to a buffer with the packed message |
911 | * @param buf_length set to the length of buf | 911 | * @param buf_length set to the length of @a buf |
912 | * @return GNUNET_SYSERR if 'p' is invalid | 912 | * @return #GNUNET_SYSERR if @a p is invalid |
913 | * GNUNET_NO if 'p' was truncated (but there is still a result in 'buf') | 913 | * #GNUNET_NO if @a p was truncated (but there is still a result in @a buf) |
914 | * GNUNET_OK if 'p' was packed completely into '*buf' | 914 | * #GNUNET_OK if @a p was packed completely into @a buf |
915 | */ | 915 | */ |
916 | int | 916 | int |
917 | GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p, | 917 | GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p, |