RDK-60308-[tr69hostif, RFC] RDK Coverity Defect Resolution for Device Management#161
RDK-60308-[tr69hostif, RFC] RDK Coverity Defect Resolution for Device Management#161Vismalskumar0 wants to merge 2 commits intodevelopfrom
Conversation
… Management RDK-60308-[tr69hostif, RFC] RDK Coverity Defect Resolution for Device Management
There was a problem hiding this comment.
Pull request overview
This PR appears to target Coverity findings in the RFC/XConf handler, focusing on memory handling, logging robustness, and minor efficiency tweaks in Device Management.
Changes:
- Added
<errno.h>and refinedIsDirectBlocked()to treatENOENTas non-fatal when removing the direct-block file, while logging detailed errno information on failure. - Reduced unnecessary string copies by using
std::movewhen passing temporary or last-usestd::stringinstances into helper methods and containers. - Tightened memory management around
hashParam_tinDownloadRuntimeFeatutres()by explicitly freeing nested heap-allocated members and nulling pointers, and made the cURL error telemetry switch exhaustive withbreak/defaulthandling.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if(file_dwnl.hashData != nullptr) | ||
| { | ||
| if(file_dwnl.hashData->hashvalue != nullptr) | ||
| { | ||
| free(file_dwnl.hashData->hashvalue); | ||
| file_dwnl.hashData->hashvalue = nullptr; | ||
| } | ||
| if(file_dwnl.hashData->hashtime != nullptr) | ||
| { | ||
| free(file_dwnl.hashData->hashtime); | ||
| file_dwnl.hashData->hashtime = nullptr; | ||
| } | ||
| free(file_dwnl.hashData); | ||
| file_dwnl.hashData = nullptr; |
There was a problem hiding this comment.
hashParam and its inner allocations are only freed via file_dwnl.hashData on the main success path, but there are several earlier return paths in this function (e.g., MTLS cert failures, cert selector init failure, or the case where pDwnLoc->pvOut/pHeaderDwnLoc->pvOut are null) that exit without hitting this cleanup, leaking both the hashParam_t struct and any strdup-allocated strings. Consider centralizing cleanup (e.g., a single exit path with a cleanup block or a small RAII helper) so that hashParam->hashvalue, hashParam->hashtime, and hashParam are released consistently on all return paths, including error conditions and the !pDwnLoc->pvOut || !pHeaderDwnLoc->pvOut case.
RDK-60308-[tr69hostif, RFC] RDK Coverity Defect Resolution for Device Management