summaryrefslogtreecommitdiff
path: root/resource/csdk
diff options
context:
space:
mode:
authorJaewook Jung <jw0213.jung@samsung.com>2017-05-19 11:02:29 +0900
committerAshok Babu Channa <ashok.channa@samsung.com>2017-05-22 06:39:32 +0000
commit043fef01bb5552562747ca01d548499445efeb4f (patch)
treed897de79c2f7540bc760e1dd574ef927d6ec71e9 /resource/csdk
parent44ca3b621136e78201bb9bd348684f2952b42745 (diff)
downloadiotivity-043fef01bb5552562747ca01d548499445efeb4f.tar.gz
iotivity-043fef01bb5552562747ca01d548499445efeb4f.tar.bz2
iotivity-043fef01bb5552562747ca01d548499445efeb4f.zip
Fix defects detected by static code analyzer
- fixed memory leak - removed unreachable codes - add a null checking before refer a character pointer Change-Id: Ie49c44f0d2e5211dec24a607382c202900b4f6a3 Signed-off-by: Jaewook Jung <jw0213.jung@samsung.com> Reviewed-on: https://gerrit.iotivity.org/gerrit/20087 Tested-by: jenkins-iotivity <jenkins@iotivity.org> Reviewed-by: Glen Youngjin Kim <glen.kim@samsung.com> Reviewed-by: Uze Choi <uzchoi@samsung.com> Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
Diffstat (limited to 'resource/csdk')
-rw-r--r--resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c6
-rwxr-xr-xresource/csdk/connectivity/src/caprotocolmessage.c6
-rw-r--r--resource/csdk/stack/src/ocstack.c23
3 files changed, 12 insertions, 23 deletions
diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c b/resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c
index cdff8bae5..1fade67cf 100644
--- a/resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c
+++ b/resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c
@@ -512,12 +512,6 @@ void CAAdapterDataSendHandler(void *context)
}
const char *remoteAddress = message->remoteEndpoint->addr;
- if(!remoteAddress)
- {
- OIC_LOG(ERROR, TAG, "EDR Send Message error");
- //Error cannot be sent if remote address is NULL
- return;
- }
CAResult_t result = CAEDRClientSendData(remoteAddress, message->data, message->dataLen);
if(CA_STATUS_OK != result)
diff --git a/resource/csdk/connectivity/src/caprotocolmessage.c b/resource/csdk/connectivity/src/caprotocolmessage.c
index ffe21e7bf..1a1890f00 100755
--- a/resource/csdk/connectivity/src/caprotocolmessage.c
+++ b/resource/csdk/connectivity/src/caprotocolmessage.c
@@ -300,12 +300,6 @@ coap_pdu_t *CAGeneratePDUImpl(code_t code, const CAInfo_t *info,
msgLength = msgLength + info->payloadSize + PAYLOAD_MARKER;
}
- if (msgLength > UINT_MAX)
- {
- OIC_LOG(ERROR, TAG, "Message length too large.");
- return NULL;
- }
-
*transport = coap_get_tcp_header_type_from_size((unsigned int)msgLength);
length = msgLength + coap_get_tcp_header_length_for_transport(*transport)
+ info->tokenLength;
diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c
index 5b183511d..4d0401039 100644
--- a/resource/csdk/stack/src/ocstack.c
+++ b/resource/csdk/stack/src/ocstack.c
@@ -3609,10 +3609,10 @@ OCStackResult OCDoRequest(OCDoHandle *handle,
goto exit;
}
#endif
-
+
#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
/* Check whether we should assert role certificates before making this request. */
- if ((endpoint.flags & CA_SECURE) &&
+ if ((endpoint.flags & CA_SECURE) && (NULL != requestInfo.info.resourceUri) &&
(strcmp(requestInfo.info.resourceUri, OIC_RSRC_ROLES_URI) != 0) &&
(strcmp(requestInfo.info.resourceUri, OIC_RSRC_DOXM_URI) != 0))
{
@@ -3620,18 +3620,19 @@ OCStackResult OCDoRequest(OCDoHandle *handle,
CAResult_t caRes = CAGetSecureEndpointData(&endpoint, &sep);
if (caRes != CA_STATUS_OK)
{
- /*
- * This is a secure request but we do not have a secure connection with
- * this peer, try to assert roles. There's no way to tell if the peer
- * uses certificates without asking, so just try to assert roles. If
+ /*
+ * This is a secure request but we do not have a secure connection with
+ * this peer, try to assert roles. There's no way to tell if the peer
+ * uses certificates without asking, so just try to assert roles. If
* it fails, that's OK, roles will get asserted "automatically" when PSK
* credentials are used.
*/
- OIC_LOG_V(DEBUG, TAG, "%s: going to try to assert roles before doing request to %s ",
+ OIC_LOG_V(DEBUG, TAG, "%s: going to try to assert roles before doing request to %s ",
__func__, requestInfo.info.resourceUri);
OCDevAddr da;
CopyEndpointToDevAddr(&endpoint, &da);
- OCStackResult assertResult = OCAssertRoles((void*)ASSERT_ROLES_CTX, &da, &assertRolesCB);
+ OCStackResult assertResult = OCAssertRoles((void*)ASSERT_ROLES_CTX, &da,
+ &assertRolesCB);
if (assertResult == OC_STACK_OK)
{
OIC_LOG_V(DEBUG, TAG, "%s: Call to OCAssertRoles succeeded", __func__);
@@ -3644,12 +3645,12 @@ OCStackResult OCDoRequest(OCDoHandle *handle,
{
OIC_LOG_V(DEBUG, TAG, "%s: Call to OCAssertRoles failed", __func__);
}
-
- /*
+
+ /*
* We don't block waiting for OCAssertRoles to complete. Because the roles assertion
* request is queued before the actual request, it will happen first. If it fails, we
* log the error, but don't retry; the actually request made to OCDorequest may or may
- * not fail (with permission denied), the caller can decide whether to retry.
+ * not fail (with permission denied), the caller can decide whether to retry.
*/
}