static void print_config_network_static_info(sa_network_static_s * staticInfo)
{
if (staticInfo != NULL) {
- if (staticInfo->ipAddress != NULL)
+ if (strlen(staticInfo->ipAddress) > 0)
_D("static::ipAddress[%s]");
- if (staticInfo->netmask != NULL)
+ if (strlen(staticInfo->netmask) > 0)
_D("static::netmask[%s]");
- if (staticInfo->defaultGateway != NULL)
+ if (strlen(staticInfo->defaultGateway) > 0)
_D("static::defaultGateway[%s]");
- if (staticInfo->primaryDnsServer != NULL)
+ if (strlen(staticInfo->primaryDnsServer) > 0)
_D("static::primaryDnsServer[%s]");
- if (staticInfo->secondaryDnsServer != NULL)
+ if (strlen(staticInfo->secondaryDnsServer) > 0)
_D("static::secondaryDnsServer[%s]");
}
}
if (wifi != NULL) {
_D("Network::wifi::enabled[%d]", wifi->enabled);
_D("Network::wifi::dhcpEnabled[%d]", wifi->dhcpEnabled);
- if (wifi->ssid != NULL)
- _D("Network::wifi::ssid[%s]", wifi->ssid);
- if (wifi->password != NULL)
- _D("Network::wifi::password[%s]", wifi->password);
+ _D("Network::wifi::ssid[%s]", wifi->ssid);
+ _D("Network::wifi::password[%s]", wifi->password);
if (wifi->dhcpEnabled == 0)
print_config_network_static_info(wifi->staticInfo);
static void print_config_info(sa_config_s * config)
{
if (config != NULL) {
- if (config->version != NULL)
- _D("Version [%s]", config->version);
+ _D("Version [%s]", config->version);
if (config->networkData)
print_network_config(config->networkData);
ipAddress = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_IPADDRESS);
if (ipAddress != NULL) {
_D("ipaddress = %s", ipAddress);
- memcpy(staticInfo->ipAddress, ipAddress, strlen(ipAddress));
+
+ memcpy(staticInfo->ipAddress, ipAddress, MIN(strlen(ipAddress), sizeof(staticInfo->ipAddress) - 1));
free(ipAddress);
ipAddress = NULL;
}
//netmask
netmask = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_NETMASK);
if (netmask != NULL) {
- memcpy(staticInfo->netmask, netmask, strlen(netmask));
+ memcpy(staticInfo->netmask, netmask, MIN(strlen(netmask), sizeof(staticInfo->netmask) - 1));
free(netmask);
netmask = NULL;
}
//defaultGateway
defaultGateway = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_DEFAULTGATEWAY);
if (defaultGateway != NULL) {
- memcpy(staticInfo->defaultGateway, defaultGateway, strlen(defaultGateway));
+ memcpy(staticInfo->defaultGateway, defaultGateway, MIN(strlen(defaultGateway), sizeof(staticInfo->defaultGateway) - 1));
free(defaultGateway);
defaultGateway = NULL;
}
//primaryDnsServer
primaryDnsServer = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_PRIMARYDNSSERVER);
if (primaryDnsServer != NULL) {
- memcpy(staticInfo->primaryDnsServer, primaryDnsServer, strlen(primaryDnsServer));
+ memcpy(staticInfo->primaryDnsServer, primaryDnsServer, MIN(strlen(primaryDnsServer), sizeof(staticInfo->primaryDnsServer) - 1));
free(primaryDnsServer);
primaryDnsServer = NULL;
}
//secondaryDnsServer
secondaryDnsServer = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_SECONDARYDNSSERVER);
if (secondaryDnsServer != NULL) {
- memcpy(staticInfo->secondaryDnsServer, secondaryDnsServer, strlen(secondaryDnsServer));
+ memcpy(staticInfo->secondaryDnsServer, secondaryDnsServer, MIN(strlen(secondaryDnsServer), sizeof(staticInfo->secondaryDnsServer) - 1));
free(secondaryDnsServer);
secondaryDnsServer = NULL;
}
void sa_inputfile_remove(void)
{
- if (remove(CONFIG_FILE) != 0)
- _E("Can't remove file{%s}! %s", CONFIG_FILE, strerror(errno));
- else
- _D("file removed successfully..{%s}", CONFIG_FILE);
+ char buff[256];
+ if (remove(CONFIG_FILE) != 0) {
+ if (strerror_r(errno, buff, sizeof(buff)) == 0)
+ _E("Can't remove file{%s}! %s", CONFIG_FILE, buff);
+ } else
+ _D("file removed successfully..{%s}", CONFIG_FILE);
}
void sa_inputfile_clear_completion_flag(void)
void sa_inputfile_set_completion_flag(sa_file_config_e config_type)
{
int fd;
+ char buff[256];
switch (config_type) {
case SA_FILE_CONFIG_SYSTEM:
break;
}
- if (fd == -1)
- _E("Can't create file for (%d)! %s", config_type, strerror(errno));
+ if (fd == -1) {
+ if (strerror_r(errno, buff, sizeof(buff)) == 0)
+ _E("Can't create file for {%d}! %s", config_type, buff);
+ } else
+ close(fd);
}
// return TRUE if set
char input_str[100] = { 0, };
_D("ipaddress =%s", info->staticInfo->ipAddress);
- if (info->staticInfo->ipAddress != NULL) {
+ if (strlen(info->staticInfo->ipAddress) > 0) {
rv = connection_profile_set_ip_address(profile, address_family, info->staticInfo->ipAddress);
if (rv != CONNECTION_ERROR_NONE)
return -1;
}
_D("netmask =%s", info->staticInfo->netmask);
- if (info->staticInfo->netmask != NULL) {
+ if (strlen(info->staticInfo->netmask) > 0) {
rv = connection_profile_set_subnet_mask(profile, address_family, info->staticInfo->netmask);
if (rv != CONNECTION_ERROR_NONE)
return -1;
}
- if (info->staticInfo->defaultGateway != NULL) {
+ if (strlen(info->staticInfo->defaultGateway) > 0) {
rv = connection_profile_set_gateway_address(profile, address_family, info->staticInfo->defaultGateway);
if (rv != CONNECTION_ERROR_NONE)
return -1;
_D("gateway =%s", info->staticInfo->defaultGateway);
}
- if (info->staticInfo->primaryDnsServer != NULL) {
+ if (strlen(info->staticInfo->primaryDnsServer) > 0) {
rv = connection_profile_set_dns_address(profile, 1, address_family, info->staticInfo->primaryDnsServer);
if (rv != CONNECTION_ERROR_NONE)
return -1;
_D("DNS 1 =%s", info->staticInfo->primaryDnsServer);
- if (info->staticInfo->secondaryDnsServer != NULL) {
+ if (strlen(info->staticInfo->secondaryDnsServer) > 0) {
rv = connection_profile_set_dns_address(profile, 2, address_family, info->staticInfo->secondaryDnsServer);
if (rv != CONNECTION_ERROR_NONE)
return -1;