aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/util/gnunet-service-resolver.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c
index d907bd8d9..3b871ce33 100644
--- a/src/util/gnunet-service-resolver.c
+++ b/src/util/gnunet-service-resolver.c
@@ -364,7 +364,7 @@ lookup_dns_servers (char ***server_addrs)
364 GNUNET_DISK_file_close (fh); 364 GNUNET_DISK_file_close (fh);
365 return -1; 365 return -1;
366 } 366 }
367 if (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. "
@@ -379,7 +379,7 @@ lookup_dns_servers (char ***server_addrs)
379 *server_addrs = NULL; 379 *server_addrs = NULL;
380 read_offset = 0; 380 read_offset = 0;
381 num_dns_servers = 0; 381 num_dns_servers = 0;
382 while (read_offset < bytes_read) 382 while (read_offset < (size_t) bytes_read)
383 { 383 {
384 const char *newline; 384 const char *newline;
385 size_t line_len; 385 size_t line_len;
@@ -648,11 +648,16 @@ try_cache (const char *hostname,
648 struct ResolveCache *pos; 648 struct ResolveCache *pos;
649 struct ResolveCache *next; 649 struct ResolveCache *next;
650 int found; 650 int found;
651 int in_hosts;
651 652
653 in_hosts = GNUNET_NO;
652 for (pos = hosts_head; NULL != pos; pos = pos->next) 654 for (pos = hosts_head; NULL != pos; pos = pos->next)
653 if (0 == strcmp (pos->hostname, 655 if (0 == strcmp (pos->hostname,
654 hostname)) 656 hostname))
657 {
658 in_hosts = GNUNET_YES;
655 break; 659 break;
660 }
656 if (NULL == pos) 661 if (NULL == pos)
657 { 662 {
658 next = cache_head; 663 next = cache_head;
@@ -673,7 +678,8 @@ try_cache (const char *hostname,
673 hostname); 678 hostname);
674 return GNUNET_NO; 679 return GNUNET_NO;
675 } 680 }
676 if (cache_head != pos) 681 if ( (GNUNET_NO == in_hosts) &&
682 (cache_head != pos) )
677 { 683 {
678 /* move result to head to achieve LRU for cache eviction */ 684 /* move result to head to achieve LRU for cache eviction */
679 GNUNET_CONTAINER_DLL_remove (cache_head, 685 GNUNET_CONTAINER_DLL_remove (cache_head,
@@ -1313,7 +1319,7 @@ extract_hosts (const char *line,
1313 if (NULL != c) 1319 if (NULL != c)
1314 line_len = c - line; 1320 line_len = c - line;
1315 /* ignore leading whitespace */ 1321 /* ignore leading whitespace */
1316 while ( (0 > line_len) && 1322 while ( (0 < line_len) &&
1317 isspace ((unsigned char) *line) ) 1323 isspace ((unsigned char) *line) )
1318 { 1324 {
1319 line++; 1325 line++;
@@ -1382,7 +1388,7 @@ load_etc_hosts (void)
1382 GNUNET_DISK_file_close (fh); 1388 GNUNET_DISK_file_close (fh);
1383 return; 1389 return;
1384 } 1390 }
1385 if (bytes_read > SIZE_MAX) 1391 if ((size_t) bytes_read > SIZE_MAX)
1386 { 1392 {
1387 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1393 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1388 "/etc/hosts file too large to mmap. " 1394 "/etc/hosts file too large to mmap. "
@@ -1395,7 +1401,7 @@ load_etc_hosts (void)
1395 GNUNET_DISK_MAP_TYPE_READ, 1401 GNUNET_DISK_MAP_TYPE_READ,
1396 (size_t) bytes_read); 1402 (size_t) bytes_read);
1397 read_offset = 0; 1403 read_offset = 0;
1398 while (read_offset < bytes_read) 1404 while (read_offset < (size_t) bytes_read)
1399 { 1405 {
1400 const char *newline; 1406 const char *newline;
1401 size_t line_len; 1407 size_t line_len;