Test l1: Do not merge#92
Conversation
Reason for change: For testing purpose only
| isModule = false; | ||
| } | ||
| if(!isModule){ | ||
| src_file.open(file); |
Check failure
Code scanning / CodeQL
Time-of-check time-of-use filesystem race condition High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 months ago
The core recommendation is to avoid the check-before-use pattern on file paths. Instead, attempt to open the file directly and, if unsuccessful, fall back to alternative locations or extensions as needed. In this concrete case, the purpose of the stat call is to check if the file exists in the current directory before searching the module path. This can be replaced by attempting to open the file directly from the current directory and, if unsuccessful, proceeding to check other locations—no separate stat is necessary. Only the file open operation should determine whether the file exists and is accessible.
Best fix:
Update the function to remove the stat call entirely and replace the check with an attempt to open the file in CWD. If the open succeeds, read the contents; otherwise, proceed to open from the module path, continue as before. This removes the time window between check and use, preventing the TOCTOU issue.
Files/regions to change:
- Edit
JavaScriptContextBase::readFilebody (lines 101–141). - Remove
statcall, replace with open-then-check for success.
Additional needs:
- No new imports needed, as fstream is already included.
- No need for additional methods or definitions.
| @@ -100,19 +100,14 @@ | ||
| }*/ | ||
| std::string JavaScriptContextBase::readFile(const char *file) | ||
| { | ||
| bool isModule = true; | ||
| std::ifstream src_file; | ||
| std::stringstream src_script; | ||
| struct stat path; | ||
|
|
||
| // Try CWD first | ||
| if(stat(file, &path) == 0){ | ||
| isModule = false; | ||
| } | ||
| if(!isModule){ | ||
| src_file.open(file); | ||
| // Try opening from current working directory first | ||
| src_file.open(file); | ||
| if(src_file.is_open()) { | ||
| src_script << src_file.rdbuf(); | ||
| return src_script.str(); // <--- Early return if found in CWD! | ||
| return src_script.str(); | ||
| } | ||
|
|
||
| // Try sModulesPath + file |
…hin a single process Reason for change: Changes related to client/server Test Procedure: build should be successful. Risks: low Priority: P2
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
RDKEMW-9355: Add Support to run app widgets in different contexts wit…
Release 2.0
LCOV - code coverage report
|
LCOV - code coverage report
|
LCOV - code coverage report
|
LCOV - code coverage report
|
Reason for change: Fixing undefined errors in during VIPA playback Test Procedure: VIPA JS version should launch using this widget. Risks: low Priority: P2
RDKEMW-11507: Viper IPA not working with rdknative widget
Release 2.0.1
Reason for change: For testing purpose only
LCOV - code coverage report
|
Reason for change: For testing purpose only