{
sockAddr.sin_addr.s_addr = inet_addr(localIp);
}
- else
- {
- sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
- }
int16_t i = 0;
bool isBound = false;
}
if (netMask)
{
- strncpy(info->subNetMask, netMask, strlen(netMask));
+ strncpy(info->subNetMask, netMask, sizeof(info->subNetMask) - 1);
+ info->subNetMask[sizeof(info->subNetMask)-1] = '\0';
OICFree(netMask);
}
- strncpy(info->ipAddress, localAddress, strlen(localAddress));
+ strncpy(info->ipAddress, localAddress, sizeof(info->ipAddress) - 1);
+ info->ipAddress[sizeof(info->ipAddress) - 1] = '\0';
info->port = *port;
info->socketFd = unicastServerFd;
info->isSecured = isSecured;
info->isServerStarted = true;
info->isMulticastServer = false;
- strncpy(info->ifAddr, localAddress, strlen(localAddress));
+ strncpy(info->ifAddr, localAddress, sizeof(info->ifAddr) - 1);
+ info->ifAddr[sizeof(info->ifAddr) - 1] = '\0';
CAResult_t res = CAAddServerInfo(g_serverInfoList, info);
if (CA_STATUS_OK != res)
}
if (netMask)
{
- strncpy(info->subNetMask, netMask, strlen(netMask));
+ strncpy(info->subNetMask, netMask, sizeof(info->subNetMask) - 1);
+ info->subNetMask[sizeof(info->subNetMask) -1] = '\0';
OICFree(netMask);
}
- strncpy(info->ipAddress, multicastAddress, strlen(multicastAddress));
+ strncpy(info->ipAddress, multicastAddress, sizeof(info->ipAddress) - 1);
+ info->ipAddress[sizeof(info->ipAddress) -1] = '\0';
info->port = multicastPort;
info->socketFd = mulicastServerFd;
info->isSecured = false;
info->isServerStarted = true;
info->isMulticastServer = true;
- strncpy(info->ifAddr, localAddress, strlen(localAddress));
+ strncpy(info->ifAddr, localAddress, sizeof(info->ifAddr)-1);
+ info->ifAddr[sizeof(info->ifAddr) -1] = '\0';
ret = CAAddServerInfo(g_serverInfoList, info);
}
CACloseSocket(info->socketFd);
OICFree(info);
- OIC_LOG_V(DEBUG, IP_SERVER_TAG,
- "Multicast server is stopped successfully on IF [%s]", info->ifAddr);
+ OIC_LOG(DEBUG, IP_SERVER_TAG, "Multicast server is stopped successfully.");
// Reduce list length by 1 as we removed one element.
listLength--;
}
{
CACloseSocket(info->socketFd);
OICFree(info);
- OIC_LOG_V(DEBUG, IP_SERVER_TAG,
- "Unicast server is stopped successfully on IF [%s]", info->ifAddr);
+ OIC_LOG(DEBUG, IP_SERVER_TAG, "Unicast server is stopped successfully.");
// Reduce list length by 1 as we removed one element.
listLength--;
}