aboutsummaryrefslogtreecommitdiff
path: root/src/util/gnunet-service-resolver.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-11-29 22:26:21 +0100
committerChristian Grothoff <christian@grothoff.org>2018-11-29 22:26:21 +0100
commite871f8368c8a1f0867f68f656875e4c37c26f298 (patch)
treec2aa6a2b40213d695e8f047a51695563f44d74b8 /src/util/gnunet-service-resolver.c
parentf8bccfbb602bdbed4bcc00fd3c6c3a00add82416 (diff)
downloadgnunet-e871f8368c8a1f0867f68f656875e4c37c26f298.tar.gz
gnunet-e871f8368c8a1f0867f68f656875e4c37c26f298.zip
finish (?) libgnunetatstransport for now
Diffstat (limited to 'src/util/gnunet-service-resolver.c')
-rw-r--r--src/util/gnunet-service-resolver.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c
index 3b871ce33..5f8957d8c 100644
--- a/src/util/gnunet-service-resolver.c
+++ b/src/util/gnunet-service-resolver.c
@@ -365,12 +365,12 @@ lookup_dns_servers (char ***server_addrs)
365 return -1; 365 return -1;
366 } 366 }
367 if ((size_t) bytes_read > SIZE_MAX) 367 if ((size_t) bytes_read > SIZE_MAX)
368 { 368 {
369 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 369 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
370 "/etc/resolv.conf file too large to mmap. " 370 "/etc/resolv.conf file too large to mmap. "
371 "DNS resolution will not be possible.\n"); 371 "DNS resolution will not be possible.\n");
372 GNUNET_DISK_file_close (fh); 372 GNUNET_DISK_file_close (fh);
373 return -1; 373 return -1;
374 } 374 }
375 buf = GNUNET_DISK_file_map (fh, 375 buf = GNUNET_DISK_file_map (fh,
376 &mh, 376 &mh,
@@ -600,7 +600,7 @@ remove_expired (struct ResolveCache *rc)
600 pos); 600 pos);
601 GNUNET_DNSPARSER_free_record (pos->record); 601 GNUNET_DNSPARSER_free_record (pos->record);
602 GNUNET_free (pos->record); 602 GNUNET_free (pos->record);
603 GNUNET_free (pos); 603 GNUNET_free (pos);
604 } 604 }
605 } 605 }
606 if (NULL == rc->records_head) 606 if (NULL == rc->records_head)
@@ -1062,7 +1062,7 @@ process_get (const char *hostname,
1062 struct GNUNET_SERVICE_Client *client) 1062 struct GNUNET_SERVICE_Client *client)
1063{ 1063{
1064 char fqdn[255]; 1064 char fqdn[255];
1065 1065
1066 if ( (NULL != my_domain) && 1066 if ( (NULL != my_domain) &&
1067 (NULL == strchr (hostname, 1067 (NULL == strchr (hostname,
1068 (unsigned char) '.')) && 1068 (unsigned char) '.')) &&
@@ -1072,7 +1072,7 @@ process_get (const char *hostname,
1072 sizeof (fqdn), 1072 sizeof (fqdn),
1073 "%s.%s", 1073 "%s.%s",
1074 hostname, 1074 hostname,
1075 my_domain); 1075 my_domain);
1076 } 1076 }
1077 else if (strlen (hostname) < 255) 1077 else if (strlen (hostname) < 255)
1078 { 1078 {
@@ -1126,15 +1126,7 @@ check_get (void *cls,
1126 direction = ntohl (get->direction); 1126 direction = ntohl (get->direction);
1127 if (GNUNET_NO == direction) 1127 if (GNUNET_NO == direction)
1128 { 1128 {
1129 /* IP from hostname */ 1129 GNUNET_MQ_check_zero_termination (get);
1130 const char *hostname;
1131
1132 hostname = (const char *) &get[1];
1133 if (hostname[size - 1] != '\0')
1134 {
1135 GNUNET_break (0);
1136 return GNUNET_SYSERR;
1137 }
1138 return GNUNET_OK; 1130 return GNUNET_OK;
1139 } 1131 }
1140 af = ntohl (get->af); 1132 af = ntohl (get->af);
@@ -1257,7 +1249,7 @@ shutdown_task (void *cls)
1257 1249
1258 1250
1259/** 1251/**
1260 * Add information about a host from /etc/hosts 1252 * Add information about a host from /etc/hosts
1261 * to our cache. 1253 * to our cache.
1262 * 1254 *
1263 * @param hostname the name of the host 1255 * @param hostname the name of the host
@@ -1278,7 +1270,7 @@ add_host (const char *hostname,
1278 rec = GNUNET_malloc (sizeof (struct GNUNET_DNSPARSER_Record)); 1270 rec = GNUNET_malloc (sizeof (struct GNUNET_DNSPARSER_Record));
1279 rec->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS; 1271 rec->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS;
1280 rec->type = rec_type; 1272 rec->type = rec_type;
1281 rec->dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET; 1273 rec->dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
1282 rec->name = GNUNET_strdup (hostname); 1274 rec->name = GNUNET_strdup (hostname);
1283 rec->data.raw.data = GNUNET_memdup (data, 1275 rec->data.raw.data = GNUNET_memdup (data,
1284 data_size); 1276 data_size);
@@ -1298,7 +1290,7 @@ add_host (const char *hostname,
1298 1290
1299/** 1291/**
1300 * Extract host information from a line in /etc/hosts 1292 * Extract host information from a line in /etc/hosts
1301 * 1293 *
1302 * @param line the line to parse 1294 * @param line the line to parse
1303 * @param line_len number of bytes in @a line 1295 * @param line_len number of bytes in @a line
1304 */ 1296 */
@@ -1389,12 +1381,12 @@ load_etc_hosts (void)
1389 return; 1381 return;
1390 } 1382 }
1391 if ((size_t) bytes_read > SIZE_MAX) 1383 if ((size_t) bytes_read > SIZE_MAX)
1392 { 1384 {
1393 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1385 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1394 "/etc/hosts file too large to mmap. " 1386 "/etc/hosts file too large to mmap. "
1395 "DNS resolution will not be possible.\n"); 1387 "DNS resolution will not be possible.\n");
1396 GNUNET_DISK_file_close (fh); 1388 GNUNET_DISK_file_close (fh);
1397 return; 1389 return;
1398 } 1390 }
1399 buf = GNUNET_DISK_file_map (fh, 1391 buf = GNUNET_DISK_file_map (fh,
1400 &mh, 1392 &mh,