if (scope != ip_scope)
continue;
- sprintf(copied, "%s:%s:%s:%s:%s:%s:%s:%s",
+ snprintf(copied, sizeof(copied), "%s:%s:%s:%s:%s:%s:%s:%s",
addr[0], addr[1], addr[2], addr[3],
addr[4], addr[5], addr[6], addr[7]);
strtok_r(link_addr, ":", &if_id);
link_addr = if_id;
}
- sprintf(copied, "%s:%s", prefix, if_id);
+ snprintf(copied, sizeof(copied), "%s:%s", prefix, if_id);
*ipv6_address = g_strdup(copied);
g_free(network_if_name);
g_free(link_addr);
g_free(network_addr);
- g_free(prefix);
g_free(if_id);
#endif
BT_DBG("Created IPv6 address [%s]", *ipv6_address);
+ g_free(prefix);
return BT_ERROR_NONE;
}
g_strlcpy(ifr.ifr_name, if_name, IFNAMSIZ);
- memset(&addr, 0, sizeof(struct sockaddr));
+ memset(&addr, 0, sizeof(struct sockaddr_in6));
addr.sin6_family = AF_INET6;
addr.sin6_port = 0;
if (inet_pton(AF_INET6, ipv6_addr, (void *)&addr.sin6_addr) <= 0) {
BT_ERR("Bad address!!");
+ close(sock_fd);
return BT_ERROR_OPERATION_FAILED;
}
pid_t pid;
char *network_if_name = NULL;
char *network_addr = NULL;
+ char *address = NULL;
if (remove(DNSMASQ_LEASES_FILE) < 0)
BT_ERR("Failed to remove %s", DNSMASQ_LEASES_FILE);
__bt_ipsp_get_network_ipv6_address(network_if_name, MOBILE_AP_IPV6_SCOPE_GLOBAL, &network_addr);
if (network_addr == NULL) {
BT_ERR("Failed to get global IP");
+ fclose(fp);
return BT_ERROR_OPERATION_FAILED;
}
- snprintf(buf, DNSMASQ_CONF_LEN, DNSMASQ_CONF6, dns_addr, g_strndup(network_addr, 19));
+ address = g_strndup(network_addr, 19);
+ snprintf(buf, DNSMASQ_CONF_LEN, DNSMASQ_CONF6, dns_addr, address);
fputs(buf, fp);
fclose(fp);
pid = fork();
if (pid < 0) {
BT_ERR("fork failed\n");
+ g_free(address);
return BT_ERROR_OPERATION_FAILED;
}
/* Invert 7th bit */
hex ^= 2;
BT_DBG("Inverted bit(%x)", hex);
- sprintf(addr64, "%x%s:%sff:fe%s:%s%s",
+ snprintf(addr64, sizeof(addr64), "%x%s:%sff:fe%s:%s%s",
hex, addr[1], addr[2], addr[3], addr[4], addr[5]);
BT_DBG("addr64(%s)", addr64);
BT_DBG("-");
}
-
int __bt_ipsp_create_ipv6_remote_address(char *remote_address, char **ipv6_address)
{
BT_DBG("++");
}
prefix = g_strndup(network_addr, 19);
- sprintf(copied, "%s:%s", prefix, eui64_addr);
+ snprintf(copied, sizeof(copied), "%s:%s", prefix, eui64_addr);
*ipv6_address = g_strdup(copied);
-
BT_DBG("remote device ipv6 addr : %s", *ipv6_address);
+
+ g_free(prefix);
BT_DBG("--");
return BT_ERROR_NONE;
-
-
}
int _execute_command(const char *cmd)