-
Notifications
You must be signed in to change notification settings - Fork 3
RDK-60308-[tr69hostif, RFC] RDK Coverity Defect Resolution for Device Management #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
731d67a
2971587
503c67b
8b76f9f
00502d4
3ac73d2
68ce168
05db83b
64cf58e
1ac5be4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
|
|
||
| /* | ||
| * If not stated otherwise in this file or this component's LICENSE file the | ||
| * following copyright and licenses apply: | ||
|
Check failure on line 4 in src/hostif/handlers/src/hostIf_IPClient_ReqHandler.cpp
|
||
| * | ||
| * Copyright 2016 RDK Management | ||
| * | ||
|
|
@@ -408,14 +408,16 @@ | |
| } | ||
| g_hash_table_insert(notifyhash,notifyKey,notifyValuePtr); | ||
| ret = OK; | ||
| // Note: notifyKey and notifyValuePtr are now owned by the hash table, don't free them | ||
| } | ||
| else | ||
| { | ||
| ret = NOK; | ||
| RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s:%d] EthernetClientReqHandler Not able to allocate Notify pointer %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->paramName); | ||
| // Free only if allocation failed and not inserted into hash table | ||
| if(notifyKey) free(notifyKey); | ||
| if(notifyValuePtr) free(notifyValuePtr); | ||
| } | ||
| free(notifyKey); //CID:85281 - Resource leak | ||
| free(notifyValuePtr); | ||
| } | ||
| else | ||
| { | ||
|
|
@@ -459,6 +461,7 @@ | |
|
|
||
| void IPClientReqHandler::checkForUpdates() | ||
| { | ||
| std::lock_guard<std::mutex> lg(m_mutex); | ||
| if (mUpdateCallback == 0) | ||
| return; | ||
|
|
||
|
|
@@ -487,11 +490,14 @@ | |
| { | ||
|
|
||
| if (ifindexes[i] > 0 && ifindexes[i] < sizeof(curNumOfInterfaceIPv4Addresses)/sizeof(curNumOfInterfaceIPv4Addresses[0])) { | ||
| int ipv4AddressNumberOfEntries = hostIf_IPInterface::getInstance (ifindexes[i])->getIPv4AddressNumberOfEntries (); | ||
| RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s:%d] ipv4AddressNumberOfEntries = %d, curNumOfInterfaceIPv4Addresses[%d] = %d\n", | ||
| __FILE__, __FUNCTION__, __LINE__, ipv4AddressNumberOfEntries, ifindexes[i], curNumOfInterfaceIPv4Addresses[ifindexes[i]]); | ||
| sprintf (objectPath, "Device.IP.Interface.%d.IPv4Address.", ifindexes[i]); | ||
| sendAddRemoveEvents (mUpdateCallback, ipv4AddressNumberOfEntries, curNumOfInterfaceIPv4Addresses[ifindexes[i]], objectPath); | ||
| hostIf_IPInterface* ipIfInst = hostIf_IPInterface::getInstance(ifindexes[i]); | ||
| if (ipIfInst) { | ||
| int ipv4AddressNumberOfEntries = ipIfInst->getIPv4AddressNumberOfEntries(); | ||
| RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s:%d] ipv4AddressNumberOfEntries = %d, curNumOfInterfaceIPv4Addresses[%d] = %d\n", | ||
| __FILE__, __FUNCTION__, __LINE__, ipv4AddressNumberOfEntries, ifindexes[i], curNumOfInterfaceIPv4Addresses[ifindexes[i]]); | ||
| sprintf (objectPath, "Device.IP.Interface.%d.IPv4Address.", ifindexes[i]); | ||
| sendAddRemoveEvents (mUpdateCallback, ipv4AddressNumberOfEntries, curNumOfInterfaceIPv4Addresses[ifindexes[i]], objectPath); | ||
| } | ||
|
Comment on lines
+493
to
+500
|
||
|
|
||
| #ifdef IPV6_SUPPORT | ||
| if (ifindexes[i] < sizeof(curNumOfInterfaceIPv6Addresses)/sizeof(curNumOfInterfaceIPv6Addresses[0])) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||
| /* | ||||||
| * If not stated otherwise in this file or this component's LICENSE file the | ||||||
| * following copyright and licenses apply: | ||||||
|
Check failure on line 3 in src/hostif/parodusClient/pal/webpa_attribute.cpp
|
||||||
| * | ||||||
| * Copyright 2016 RDK Management | ||||||
| * | ||||||
|
|
@@ -155,9 +155,16 @@ | |||||
| strncpy(Param.paramName,pParameterName,strlen(pParameterName)+1); | ||||||
| Param.instanceNum = 0; | ||||||
| Param.paramtype = hostIf_IntegerType; | ||||||
| get_AttribValues_tr69hostIf(&Param); | ||||||
| strncpy(attr[0][i]->value,Param.paramValue, strlen(Param.paramValue)); | ||||||
| attr[0][i]->value[strlen(Param.paramValue)] = '\0'; | ||||||
| int ret = get_AttribValues_tr69hostIf(&Param); | ||||||
| if(ret == 0 && Param.paramValue != NULL) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coverity Issue - Array compared against 0Comparing an array to null is not useful: "Param.paramValue != NULL", since the test will always evaluate as true. Medium Impact, CWE-398 How to fixWas "Param.paramValue" formerly declared as a pointer?
|
||||||
| if(ret == 0 && Param.paramValue != NULL) | |
| if(ret == 0 && Param.paramValue[0] != '\0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The null check is only added for the IPv4 case but not for the IPv6 case. Lines 503 and 509 still call
hostIf_IPInterface::getInstance(ifindexes[i])without checking if the returned pointer is null before calling methods on it. This creates an inconsistency where the IPv4 code path is protected but the IPv6 code path is not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback