From 4c7aa6ff2d06e206539002fd2f66efcdf963c0dd Mon Sep 17 00:00:00 2001 From: Pavan Kumar Reddy B <57708013+pavankumar464@users.noreply.github.com> Date: Tue, 5 May 2026 12:22:48 +0530 Subject: [PATCH 1/2] RDKB-63696 CMXB7-6329 CPU & Load average spike and jst crash during stability test (#15) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- source/jst_cosa.c | 49 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/source/jst_cosa.c b/source/jst_cosa.c index 0e2428a..b270bda 100644 --- a/source/jst_cosa.c +++ b/source/jst_cosa.c @@ -408,17 +408,45 @@ static duk_ret_t getInstanceIds(duk_context *ctx) &pInstNumList ); - if (iReturn != CCSP_SUCCESS) + if (iReturn != CCSP_SUCCESS || InstNum == 0 || pInstNumList == NULL) { //AnscTraceWarning("Failed on CcspBaseIf_GetNextLevelInstances, error code = %d.\n", iReturn); //RETURN_STRING("ERROR: Failed on CcspBaseIf_GetNextLevelInstances",1); + if (ppDestComponentName) { free(ppDestComponentName); ppDestComponentName = NULL; } + if (ppDestPath) { free(ppDestPath); ppDestPath = NULL; } RETURN_STRING(""); } - for(loop1=0,loop2=0; loop1<(InstNum); loop1++) + /* Build comma-separated instance list safely */ + for (loop1 = 0, loop2 = 0; loop1 < InstNum; loop1++) { - len =sprintf(&format_s[loop2],"%d,", pInstNumList[loop1]); - loop2=loop2+len; + unsigned int prev_loop2 = loop2; + + if (loop2 >= (int)(sizeof(format_s) - 1)) + { + break; + } + + len = snprintf( + &format_s[loop2], + sizeof(format_s) - loop2, + "%u,", + pInstNumList[loop1]); + + if (len <= 0) + { + break; + } + + if (len >= (int)(sizeof(format_s) - loop2)) + { + /* Truncation: discard the partial write so only complete ids remain */ + format_s[prev_loop2] = '\0'; + loop2 = prev_loop2; + break; + } + + loop2 += len; } if (pInstNumList) @@ -426,16 +454,19 @@ static duk_ret_t getInstanceIds(duk_context *ctx) free(pInstNumList); } - //Place NULL char at the end of string - if (loop2 >= 1) + if (ppDestComponentName) { free(ppDestComponentName); ppDestComponentName = NULL; } + if (ppDestPath) { free(ppDestPath); ppDestPath = NULL; } + + /* Remove trailing comma safely */ + if (loop2 > 0 && format_s[loop2 - 1] == ',') { - format_s[loop2-1]=0; + format_s[loop2 - 1] = '\0'; } else { - format_s[0]=0; - CosaPhpExtLog("loop2-1 is less than zero in format_s[]\n"); + format_s[loop2] = '\0'; } + RETURN_STRING(format_s); } From 32e56da5db64fa93f399f27867a83cccdcabf1ac Mon Sep 17 00:00:00 2001 From: bunnam988 Date: Thu, 7 May 2026 10:13:31 +0000 Subject: [PATCH 2/2] Add changelog for release 2.1.0 --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c872c14..7909404 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -#### [2.0.0](https://github.com/rdkcentral/javascript-templates/compare/1.0.1...2.0.0) +#### [2.1.0](https://github.com/rdkcentral/javascript-templates/compare/2.0.0...2.1.0) + +- RDKB-63696 CMXB7-6329 CPU & Load average spike and jst crash during stability test [`#15`](https://github.com/rdkcentral/javascript-templates/pull/15) +- Merge tag '2.0.0' into develop [`591bc95`](https://github.com/rdkcentral/javascript-templates/commit/591bc9532ad335d4ed3a3e7b962854f8c63263e8) + +### [2.0.0](https://github.com/rdkcentral/javascript-templates/compare/1.0.1...2.0.0) + +> 4 March 2026 - RDKB-63154 RDKB-63013 Native Build Integration [`#10`](https://github.com/rdkcentral/javascript-templates/pull/10) - Deploy fossid_integration_stateless_diffscan_target_repo action [`#9`](https://github.com/rdkcentral/javascript-templates/pull/9) - Deploy cla action [`#6`](https://github.com/rdkcentral/javascript-templates/pull/6) +- Add changelog for release 2.0.0 [`116a000`](https://github.com/rdkcentral/javascript-templates/commit/116a000a495ed2513bb60b33fb17f6547cf87ab7) - Merge tag '1.0.1' into develop [`b57e33b`](https://github.com/rdkcentral/javascript-templates/commit/b57e33b30cde9886736a441e3d1be158759a0f5b) #### [1.0.1](https://github.com/rdkcentral/javascript-templates/compare/1.0.0...1.0.1)