Commit f6f29244 authored by bg.chun's avatar bg.chun Committed by Uze Choi

fix unsafe functions(strcpy, sprintf)

fix strcpy -> strncpy
fix sprinrf -> snprintf

Change-Id: Ic228e3735fe3b329ec3116a393406892d0f127e2
Signed-off-by: default avatarbg.chun <bg.chun@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18961Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarJaewook Jung <jw0213.jung@samsung.com>
Reviewed-by: default avatarJaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: default avatarDan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
parent 5d21a4a9
......@@ -246,19 +246,22 @@ char* OCCreateEndpointString(const OCEndpointPayload* endpoint)
if (endpoint->family & OC_IP_USE_V4)
{
// ipv4
sprintf(buf, "%s://%s:%d", endpoint->tps, endpoint->addr, endpoint->port);
snprintf(buf, MAX_ADDR_STR_SIZE, "%s://%s:%d", endpoint->tps,
endpoint->addr, endpoint->port);
}
else
{
// ipv6
sprintf(buf, "%s://[%s]:%d", endpoint->tps, endpoint->addr, endpoint->port);
snprintf(buf, MAX_ADDR_STR_SIZE, "%s://[%s]:%d", endpoint->tps,
endpoint->addr, endpoint->port);
}
}
#ifdef EDR_ADAPTER
else if ((strcmp(endpoint->tps, COAP_RFCOMM_STR) == 0))
{
// coap+rfcomm
sprintf(buf, "%s://%s", endpoint->tps, endpoint->addr);
snprintf(buf, MAX_ADDR_STR_SIZE, "%s://%s",
endpoint->tps, endpoint->addr);
}
#endif
else
......@@ -302,18 +305,20 @@ char* OCCreateEndpointStringFromCA(const CAEndpoint_t* endpoint)
if (endpoint->flags & CA_IPV4)
{
// ipv4
sprintf(buf, "%s://%s:%d", ConvertTpsToString(tps), endpoint->addr, endpoint->port);
snprintf(buf, MAX_ADDR_STR_SIZE, "%s://%s:%d", ConvertTpsToString(tps),
endpoint->addr, endpoint->port);
}
else
{
// ipv6
sprintf(buf, "%s://[%s]:%d", ConvertTpsToString(tps), endpoint->addr, endpoint->port);
snprintf(buf, MAX_ADDR_STR_SIZE, "%s://[%s]:%d", ConvertTpsToString(tps),
endpoint->addr, endpoint->port);
}
break;
#ifdef EDR_ADAPTER
case OC_COAP_RFCOMM:
// coap+rfcomm
sprintf(buf, "%s://%s", ConvertTpsToString(tps), endpoint->addr);
snprintf(buf, MAX_ADDR_STR_SIZE, "%s://%s", ConvertTpsToString(tps), endpoint->addr);
break;
#endif
default:
......@@ -416,7 +421,7 @@ OCStackResult OCParseEndpointString(const char* endpointStr, OCEndpointPayload*
{
// copy addr
tokPos = tokPos + 3;
ret = strcpy(addr, tokPos);
ret = OICStrcpy(addr, OC_MAX_ADDR_STR_SIZE, tokPos);
VERIFY_NON_NULL(ret);
out->tps = tps;
out->addr = addr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment