aboutsummaryrefslogtreecommitdiff
path: root/src/gns/plugin_gnsrecord_gns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns/plugin_gnsrecord_gns.c')
-rw-r--r--src/gns/plugin_gnsrecord_gns.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/src/gns/plugin_gnsrecord_gns.c b/src/gns/plugin_gnsrecord_gns.c
index cffd5a965..52c35ce10 100644
--- a/src/gns/plugin_gnsrecord_gns.c
+++ b/src/gns/plugin_gnsrecord_gns.c
@@ -72,14 +72,25 @@ gns_value_to_string (void *cls,
72 72
73 off = 0; 73 off = 0;
74 ns = GNUNET_DNSPARSER_parse_name (data, data_size, &off); 74 ns = GNUNET_DNSPARSER_parse_name (data, data_size, &off);
75 if (NULL == ns)
76 {
77 GNUNET_break_op (0);
78 GNUNET_free_non_null (ns);
79 return NULL;
80 }
81#ifndef LSD001 //DNS server IP/name must be UTF-8
82 ip = GNUNET_strdup((char*) &data[off]);
83#else
84 // Must be IP or DNS name
75 ip = GNUNET_DNSPARSER_parse_name (data, data_size, &off); 85 ip = GNUNET_DNSPARSER_parse_name (data, data_size, &off);
76 if ((NULL == ns) || (NULL == ip) || (off != data_size)) 86 if ((NULL == ip) || (off != data_size))
77 { 87 {
78 GNUNET_break_op (0); 88 GNUNET_break_op (0);
79 GNUNET_free_non_null (ns); 89 GNUNET_free_non_null (ns);
80 GNUNET_free_non_null (ip); 90 GNUNET_free_non_null (ip);
81 return NULL; 91 return NULL;
82 } 92 }
93#endif
83 GNUNET_asprintf (&nstr, "%s@%s", ns, ip); 94 GNUNET_asprintf (&nstr, "%s@%s", ns, ip);
84 GNUNET_free_non_null (ns); 95 GNUNET_free_non_null (ns);
85 GNUNET_free_non_null (ip); 96 GNUNET_free_non_null (ip);
@@ -203,19 +214,33 @@ gns_string_to_value (void *cls,
203 at++; 214 at++;
204 215
205 off = 0; 216 off = 0;
206 if ((GNUNET_OK != GNUNET_DNSPARSER_builder_add_name (nsbuf, 217 if (GNUNET_OK != GNUNET_DNSPARSER_builder_add_name (nsbuf,
207 sizeof(nsbuf), 218 sizeof(nsbuf),
208 &off, 219 &off,
209 cpy)) || 220 cpy))
210 (GNUNET_OK != 221 {
211 GNUNET_DNSPARSER_builder_add_name (nsbuf, sizeof(nsbuf), &off, at))) 222 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
223 _ (
224 "Failed to serialize GNS2DNS record with value `%s': Not a DNS name.\n"),
225 s);
226 GNUNET_free (cpy);
227 return GNUNET_SYSERR;
228 }
229#ifndef LSD001 //The DNS server location/name is in UTF-8
230 GNUNET_memcpy (&nsbuf[off], at, strlen (at) + 1);
231 off += strlen (at) + 1;
232#else
233 if (GNUNET_OK !=
234 GNUNET_DNSPARSER_builder_add_name (nsbuf, sizeof(nsbuf), &off, at))
212 { 235 {
213 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 236 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
214 _ ("Failed to serialize GNS2DNS record with value `%s'\n"), 237 _ (
238 "Failed to serialize GNS2DNS record with value `%s': Not a DNS name\n"),
215 s); 239 s);
216 GNUNET_free (cpy); 240 GNUNET_free (cpy);
217 return GNUNET_SYSERR; 241 return GNUNET_SYSERR;
218 } 242 }
243#endif
219 GNUNET_free (cpy); 244 GNUNET_free (cpy);
220 *data_size = off; 245 *data_size = off;
221 *data = GNUNET_malloc (off); 246 *data = GNUNET_malloc (off);