-
Notifications
You must be signed in to change notification settings - Fork 4
RDKEMW-8587: consume the config variables using dlsym() in MW. #168
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
1374c07
6b95abb
2f17837
2e068a5
6fd6b4f
9932c3c
cc2121a
0d13c48
397cf75
8433557
51c8af5
020d7fc
7e8a9f4
b1e9412
661e8ec
bbe42f2
299bf52
5f5a634
6553c8f
12f0193
565dbde
17faa45
8f60d7e
7455db3
8e51e51
329c312
1928496
05aa70f
64a4609
9789231
dde8258
edb8f55
2864e49
e287d3a
bccfc77
103ec2a
76d0910
acd9e70
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,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 ds/audioOutputPortConfig.cpp
|
||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * Copyright 2016 RDK Management | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
|
|
@@ -34,6 +34,17 @@ | |||||||||||||||||||||
| #include "dsUtl.h" | ||||||||||||||||||||||
| #include "stdlib.h" | ||||||||||||||||||||||
| #include "dslogger.h" | ||||||||||||||||||||||
| #include <dlfcn.h> | ||||||||||||||||||||||
| #include "manager.hpp" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| typedef struct audioConfigs | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| const dsAudioTypeConfig_t *pKConfigs; | ||||||||||||||||||||||
| const dsAudioPortConfig_t *pKPorts; | ||||||||||||||||||||||
| int *pKConfigSize; | ||||||||||||||||||||||
| int *pKPortSize; | ||||||||||||||||||||||
| }audioConfigs_t; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| namespace device { | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -108,8 +119,65 @@ | |||||||||||||||||||||
| return supportedTypes; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| void dumpconfig(audioConfigs_t *config) | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| INT_INFO("\n\n=========================================================================================================================\n\n"); | ||||||||||||||||||||||
| if(config->pKConfigs != NULL && *(config->pKConfigSize) != -1) | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); | ||||||||||||||||||||||
|
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. instead of using INT_INFO and creating macro for "#define DEBUG 1 /" use INT_DEBUG and remove macro
Author
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. I will do change to INT_DEBUG in final review before merge since debug logs are not coming. |
||||||||||||||||||||||
| INT_INFO("%d:%s: pKConfigs = %p\n", __LINE__, __func__, config->pKConfigs); | ||||||||||||||||||||||
| INT_INFO("%d:%s: pKPorts = %p\n", __LINE__, __func__, config->pKPorts); | ||||||||||||||||||||||
| INT_INFO("%d:%s: pKConfigSize addr =%p \n", __LINE__, __func__, config->pKConfigSize); | ||||||||||||||||||||||
| INT_INFO("%d:%s: pKConfigSize value = %d \n", __LINE__, __func__, *(config->pKConfigSize)); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| for (size_t i = 0; i < *(config->pKConfigSize); i++) { | ||||||||||||||||||||||
| const dsAudioTypeConfig_t *typeCfg = &(config->pKConfigs[i]); | ||||||||||||||||||||||
| INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); | ||||||||||||||||||||||
| INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); | ||||||||||||||||||||||
| INT_INFO("%d:%s: typeCfg->numSupportedEncodings = %zu\n", __LINE__, __func__, typeCfg->numSupportedEncodings); | ||||||||||||||||||||||
| INT_INFO("%d:%s: typeCfg->numSupportedCompressions = %zu\n", __LINE__, __func__, typeCfg->numSupportedCompressions); | ||||||||||||||||||||||
| INT_INFO("%d:%s: typeCfg->numSupportedStereoModes = %zu\n", __LINE__, __func__, typeCfg->numSupportedStereoModes); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| else | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| INT_ERROR("%d:%s: kAudioConfigs is NULL and *(config->pKConfigSize) is -1\n", __LINE__, __func__); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| if(config->pKPorts != NULL && *(config->pKPortSize) != -1) | ||||||||||||||||||||||
|
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. Please add null check for pKPortSize since it is pointer variable
Author
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. Done. |
||||||||||||||||||||||
| { | ||||||||||||||||||||||
| INT_INFO("%d:%s: pKPortSize addr = %p \n", __LINE__, __func__, config->pKPortSize); | ||||||||||||||||||||||
| INT_INFO("%d:%s: pKPortSize value = %d \n", __LINE__, __func__, *(config->pKPortSize)); | ||||||||||||||||||||||
| for (size_t i = 0; i < *(config->pKPortSize); i++) { | ||||||||||||||||||||||
| const dsAudioPortConfig_t *port = &(config->pKPorts[i]); | ||||||||||||||||||||||
| INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); | ||||||||||||||||||||||
| INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| else | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| INT_ERROR("%d:%s: kAudioPorts is NULL and *(config->pKPortSize) is -1\n", __LINE__, __func__); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| INT_INFO("\n\n=========================================================================================================================\n\n"); | ||||||||||||||||||||||
| INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| void AudioOutputPortConfig::load() | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| static int configSize, portSize, invalidSize = -1; | ||||||||||||||||||||||
| static audioConfigs_t configuration = {0}; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const char* searchVaribles[] = { | ||||||||||||||||||||||
|
||||||||||||||||||||||
| const char* searchVaribles[] = { | |
| const char* searchVariables[] = { |
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.
Do we need fallbacks to default configs if pKConfigSize, pKPorts and pKPortSize are not present in the library
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.
We can not mix the new and old configs.
Copilot
AI
Nov 14, 2025
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.
Local stack variables configSize and portSize may go out of scope while their addresses are still stored in the configuration struct and used later. When the fallback path is taken (lines 226-231), these local variables' addresses are stored and later dereferenced at lines 247 and 268. This results in undefined behavior.
The variables should be declared as static or the configuration struct should store the values directly instead of pointers to local variables.
| configuration.pKConfigs = kConfigs; | |
| configSize = dsUTL_DIM(kConfigs); | |
| configuration.pKConfigSize = &configSize; | |
| configuration.pKPorts = kPorts; | |
| configuration.pKConfigs = kConfigs; | |
| static int configSize; | |
| configSize = dsUTL_DIM(kConfigs); | |
| configuration.pKConfigSize = &configSize; | |
| configuration.pKPorts = kPorts; | |
| static int portSize; |
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.
Added the static in the start of funcation and using same here.
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.
Coverity Issue - Dereference after null check
Passing "&configuration" to "dumpconfig", which dereferences null "configuration.pKConfigSize".
Medium Impact, CWE-476
FORWARD_NULL
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.
I have validated all the structure pointers then calling dumpconfig() fauntion. so this comment is invalid.
Uh oh!
There was an error while loading. Please reload this page.
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.
Enable copilit as reviewr so fix all issue reported by copilot. Also review whole file and make sure null check added as poineted by Yuva
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.
I have addressed all the review comments from you, Yuva, and Copilot, except for the new one related to the deumconfig() API. This function is being called only after performing the necessary validation in the caller function, and then the call is made accordingly.