* address.
*/
static uint32_t
-extract_ipv4(const uint8_t ipv6[16], const int offset)
+extract_ipv4(const uint8_t ipv6[], size_t ipv6_len, const int offset)
{
- uint32_t ipv4 = (uint32_t)ipv6[offset/8+0] << (24 + (offset%8))
- | (uint32_t)ipv6[offset/8+1] << (16 + (offset%8))
- | (uint32_t)ipv6[offset/8+2] << ( 8 + (offset%8))
- | (uint32_t)ipv6[offset/8+3] << ( 0 + (offset%8));
+ uint32_t ipv4;
+ log_assert(ipv6_len == 16); (void)ipv6_len;
+ ipv4 = (uint32_t)ipv6[offset/8+0] << (24 + (offset%8))
+ | (uint32_t)ipv6[offset/8+1] << (16 + (offset%8))
+ | (uint32_t)ipv6[offset/8+2] << ( 8 + (offset%8))
+ | (uint32_t)ipv6[offset/8+3] << ( 0 + (offset%8));
if (offset/8+4 < 16)
ipv4 |= (uint32_t)ipv6[offset/8+4] >> (8 - offset%8);
return ipv4;
* \return The number of characters written.
*/
static size_t
-ipv4_to_ptr(uint32_t ipv4, char ptr[MAX_PTR_QNAME_IPV4])
+ipv4_to_ptr(uint32_t ipv4, char ptr[], size_t nm_len)
{
static const char IPV4_PTR_SUFFIX[] = "\07in-addr\04arpa";
int i;
for (i = 0; i < 4; ++i) {
*c = uitoa((unsigned int)(ipv4 % 256), c + 1);
c += *c + 1;
+ log_assert(c < ptr+nm_len);
ipv4 /= 256;
}
+ log_assert(c + sizeof(IPV4_PTR_SUFFIX) <= ptr+nm_len);
memmove(c, IPV4_PTR_SUFFIX, sizeof(IPV4_PTR_SUFFIX));
return c + sizeof(IPV4_PTR_SUFFIX) - ptr;
* \return 1 on success, 0 on failure.
*/
static int
-ptr_to_ipv6(const char* ptr, uint8_t ipv6[16])
+ptr_to_ipv6(const char* ptr, uint8_t ipv6[], size_t ipv6_len)
{
int i;
+ log_assert(ipv6_len == 16); (void)ipv6_len;
for (i = 0; i < 64; i++) {
int x;
* \param aaaa IPv6 address. The result will be written here.
*/
static void
-synthesize_aaaa(const uint8_t prefix_addr[16], int prefix_net,
- const uint8_t a[4], uint8_t aaaa[16])
+synthesize_aaaa(const uint8_t prefix_addr[], size_t prefix_addr_len,
+ int prefix_net, const uint8_t a[], size_t a_len, uint8_t aaaa[],
+ size_t aaaa_len)
{
+ log_assert(prefix_addr_len == 16 && a_len == 4 && aaaa_len == 16);
+ (void)prefix_addr_len; (void)a_len; (void)aaaa_len;
memcpy(aaaa, prefix_addr, 16);
aaaa[prefix_net/8+0] |= a[0] >> (0+prefix_net%8);
aaaa[prefix_net/8+1] |= a[0] << (8-prefix_net%8);
/* Convert the PTR query string to an IPv6 address. */
memset(&sin6, 0, sizeof(sin6));
sin6.sin6_family = AF_INET6;
- if (!ptr_to_ipv6((char*)qstate->qinfo.qname, sin6.sin6_addr.s6_addr))
+ if (!ptr_to_ipv6((char*)qstate->qinfo.qname, sin6.sin6_addr.s6_addr,
+ sizeof(sin6.sin6_addr.s6_addr)))
return module_wait_module; /* Let other module handle this. */
/*
if (!(qinfo.qname = regional_alloc(qstate->region, MAX_PTR_QNAME_IPV4)))
return module_error;
qinfo.qname_len = ipv4_to_ptr(extract_ipv4(sin6.sin6_addr.s6_addr,
- dns64_env->prefix_net), (char*)qinfo.qname);
+ sizeof(sin6.sin6_addr.s6_addr), dns64_env->prefix_net),
+ (char*)qinfo.qname, MAX_PTR_QNAME_IPV4);
/* Create the new sub-query. */
fptr_ok(fptr_whitelist_modenv_attach_sub(qstate->env->attach_sub));
dd->rr_data[i][1] = 16;
synthesize_aaaa(
((struct sockaddr_in6*)&dns64_env->prefix_addr)->sin6_addr.s6_addr,
+ sizeof(((struct sockaddr_in6*)&dns64_env->prefix_addr)->sin6_addr.s6_addr),
dns64_env->prefix_net, &fd->rr_data[i][2],
- &dd->rr_data[i][2] );
+ fd->rr_len[i]-2, &dd->rr_data[i][2],
+ dd->rr_len[i]-2);
dd->rr_ttl[i] = fd->rr_ttl[i];
}
struct ub_stats_info *stat_info;
int offset;
+#ifndef S_SPLINT_S
verbose(VERB_DETAIL, "SHM run - worker [%d] - daemon [%p] - timenow(%u) - timeboot(%u)",
worker->thread_num, worker->daemon, (unsigned)worker->env.now_tv->tv_sec, (unsigned)worker->daemon->time_boot.tv_sec);
+#endif
offset = worker->thread_num + 1;
stat_total = worker->daemon->shm_info->ptr_arr;
memset(stat_total, 0, sizeof(struct ub_stats_info));
/* Point to data into SHM */
+#ifndef S_SPLINT_S
shm_stat = worker->daemon->shm_info->ptr_ctl;
shm_stat->time.now_sec = (long long)worker->env.now_tv->tv_sec;
shm_stat->time.now_usec = (long long)worker->env.now_tv->tv_usec;
+#endif
stat_timeval_subtract(&shm_stat->time.up_sec, &shm_stat->time.up_usec, worker->env.now_tv, &worker->daemon->time_boot);
stat_timeval_subtract(&shm_stat->time.elapsed_sec, &shm_stat->time.elapsed_usec, worker->env.now_tv, &worker->daemon->time_last_stat);