aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-09-30 18:00:11 +0000
committerChristian Grothoff <christian@grothoff.org>2012-09-30 18:00:11 +0000
commit0a935df6e929a37aa13ebe9319d7b7217c3d8c39 (patch)
treed9a3806c074d3c90b1a6e6c759740cc001bb4669 /src/gns
parentafa2eab6a2f761058ee4c3924ca4707e3d96513f (diff)
downloadgnunet-0a935df6e929a37aa13ebe9319d7b7217c3d8c39.tar.gz
gnunet-0a935df6e929a37aa13ebe9319d7b7217c3d8c39.zip
-doxygen fix, fix off-by-one
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gnunet-service-gns_resolver.c57
1 files changed, 33 insertions, 24 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index ae576c908..964f798d0 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -2425,46 +2425,50 @@ process_delegation_result_dht(void* cls,
2425 2425
2426 2426
2427/** 2427/**
2428 * Exands a name ending in .+ with the zone of origin 2428 * Exands a name ending in .+ with the zone of origin.
2429 * FIXME: funky api: 'dest' must be large enough to hold
2430 * the result; this is a bit yucky...
2429 * 2431 *
2430 * @param dest destination buffer 2432 * @param dest destination buffer
2431 * @param sec the .+ name 2433 * @param src the .+ name
2432 * @param repl the string to replace the + with 2434 * @param repl the string to replace the + with
2433 */ 2435 */
2434static void 2436static void
2435expand_plus(char* dest, char* src, char* repl) 2437expand_plus (char* dest,
2438 const char* src,
2439 const char* repl)
2436{ 2440{
2437 char* pos; 2441 char* pos;
2438 unsigned int s_len = strlen(src)+1; 2442 size_t s_len = strlen (src) + 1;
2439 2443
2440 //Eh? I guess this is at least strlen ('x.+') == 3 FIXME 2444 //Eh? I guess this is at least strlen ('x.+') == 3 FIXME
2441 if (3 > s_len) 2445 if (3 > s_len)
2442 { 2446 {
2447 /* no postprocessing */
2443 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2448 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2444 "GNS_POSTPROCESS: %s too short\n", src); 2449 "GNS_POSTPROCESS: %s too short\n", src);
2445 2450 memcpy (dest, src, s_len);
2446 /* no postprocessing */
2447 memcpy(dest, src, s_len+1);
2448 return; 2451 return;
2449 } 2452 }
2450 2453 if (0 == strcmp (src + s_len - 3, ".+"))
2451 if (0 == strcmp(src+s_len-3, ".+"))
2452 { 2454 {
2453 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2455 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2454 "GNS_POSTPROCESS: Expanding .+ in %s\n", src); 2456 "GNS_POSTPROCESS: Expanding .+ in %s\n",
2455 memset(dest, 0, s_len+strlen(repl)+strlen(GNUNET_GNS_TLD)); 2457 src);
2456 strcpy(dest, src); 2458 memset (dest, 0, s_len + strlen (repl) + strlen(GNUNET_GNS_TLD));
2457 pos = dest+s_len-2; 2459 strcpy (dest, src);
2458 strcpy(pos, repl); 2460 pos = dest + s_len - 2;
2459 pos += strlen(repl); 2461 strcpy (pos, repl);
2460 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2462 pos += strlen (repl);
2461 "GNS_POSTPROCESS: Expanded to %s\n", dest); 2463 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2464 "GNS_POSTPROCESS: Expanded to %s\n",
2465 dest);
2462 } 2466 }
2463 else 2467 else
2464 { 2468 {
2465 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2469 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2466 "GNS_POSTPROCESS: No postprocessing for %s\n", src); 2470 "GNS_POSTPROCESS: No postprocessing for %s\n", src);
2467 memcpy(dest, src, s_len+1); 2471 memcpy (dest, src, s_len);
2468 } 2472 }
2469} 2473}
2470 2474
@@ -2534,11 +2538,12 @@ finish_lookup (struct ResolverHandle *rh,
2534 if (GNUNET_GNS_RECORD_MX == rd[i].record_type) 2538 if (GNUNET_GNS_RECORD_MX == rd[i].record_type)
2535 { 2539 {
2536 memcpy (new_mx_data, (char*)rd[i].data, sizeof(uint16_t)); 2540 memcpy (new_mx_data, (char*)rd[i].data, sizeof(uint16_t));
2537 offset = sizeof(uint16_t); 2541 offset = sizeof (uint16_t);
2538 pos = new_mx_data+offset; 2542 pos = new_mx_data + offset;
2539 expand_plus(pos, (char*)rd[i].data+sizeof(uint16_t), 2543 // FIXME: how do we know that 'pos' has enough space for the new name?
2540 repl_string); 2544 expand_plus (pos, (char*)rd[i].data+sizeof(uint16_t),
2541 offset += strlen(new_mx_data+sizeof(uint16_t))+1; 2545 repl_string);
2546 offset += strlen(new_mx_data+sizeof(uint16_t)) + 1;
2542 p_rd[i].data = new_mx_data; 2547 p_rd[i].data = new_mx_data;
2543 p_rd[i].data_size = offset; 2548 p_rd[i].data_size = offset;
2544 } 2549 }
@@ -2552,6 +2557,7 @@ finish_lookup (struct ResolverHandle *rh,
2552 new_srv->prio = old_srv->prio; 2557 new_srv->prio = old_srv->prio;
2553 new_srv->weight = old_srv->weight; 2558 new_srv->weight = old_srv->weight;
2554 new_srv->port = old_srv->port; 2559 new_srv->port = old_srv->port;
2560 // FIXME: how do we know that '&new_srv[1]' has enough space for the new name?
2555 expand_plus((char*)&new_srv[1], (char*)&old_srv[1], 2561 expand_plus((char*)&new_srv[1], (char*)&old_srv[1],
2556 repl_string); 2562 repl_string);
2557 p_rd[i].data = new_srv_data; 2563 p_rd[i].data = new_srv_data;
@@ -2563,8 +2569,10 @@ finish_lookup (struct ResolverHandle *rh,
2563 old_soa = (struct soa_data*)rd[i].data; 2569 old_soa = (struct soa_data*)rd[i].data;
2564 new_soa = (struct soa_data*)new_soa_data; 2570 new_soa = (struct soa_data*)new_soa_data;
2565 memcpy (new_soa, old_soa, sizeof (struct soa_data)); 2571 memcpy (new_soa, old_soa, sizeof (struct soa_data));
2572 // FIXME: how do we know that 'new_soa[1]' has enough space for the new name?
2566 expand_plus((char*)&new_soa[1], (char*)&old_soa[1], repl_string); 2573 expand_plus((char*)&new_soa[1], (char*)&old_soa[1], repl_string);
2567 offset = strlen ((char*)&new_soa[1]) + 1; 2574 offset = strlen ((char*)&new_soa[1]) + 1;
2575 // FIXME: how do we know that 'new_soa[1]' has enough space for the new name?
2568 expand_plus((char*)&new_soa[1] + offset, 2576 expand_plus((char*)&new_soa[1] + offset,
2569 (char*)&old_soa[1] + strlen ((char*)&old_soa[1]) + 1, 2577 (char*)&old_soa[1] + strlen ((char*)&old_soa[1]) + 1,
2570 repl_string); 2578 repl_string);
@@ -2576,6 +2584,7 @@ finish_lookup (struct ResolverHandle *rh,
2576 else 2584 else
2577 { 2585 {
2578 pos = new_rr_data; 2586 pos = new_rr_data;
2587 // FIXME: how do we know that 'rd[i].data' has enough space for the new name?
2579 expand_plus(pos, (char*)rd[i].data, repl_string); 2588 expand_plus(pos, (char*)rd[i].data, repl_string);
2580 p_rd[i].data_size = strlen(new_rr_data)+1; 2589 p_rd[i].data_size = strlen(new_rr_data)+1;
2581 p_rd[i].data = new_rr_data; 2590 p_rd[i].data = new_rr_data;