From 0223745c33b08d4321e1f2312a651058315eea77 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Wed, 23 Sep 2026 17:01:09 -0400 Subject: [PATCH] =?UTF-8?q?RDKB-64502:=20[RDKB][TELEMETRY2=5F0]=20Multi?= =?UTF-8?q?=E2=80=91profile=20config=20using=20method=20=3D=20subscribe,?= =?UTF-8?q?=20logs=20null=20&=20empty=20values=20(#406)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update reportgen.c * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Update profile.c * Update profilexconf.c * Update profile.c * Update profilexconf.c --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- source/bulkdata/profile.c | 36 ++++++++++++++++++++++++++++++---- source/bulkdata/profilexconf.c | 35 ++++++++++++++++++++++++++++++--- source/reportgen/reportgen.c | 7 +++++++ 3 files changed, 71 insertions(+), 7 deletions(-) diff --git a/source/bulkdata/profile.c b/source/bulkdata/profile.c index ec02fac1..44239c54 100644 --- a/source/bulkdata/profile.c +++ b/source/bulkdata/profile.c @@ -67,6 +67,19 @@ typedef struct __triggerConditionObj__ char referenceValue[MAX_LEN]; } triggerConditionObj ; +static bool isEmptySubscriberValue(const char *value) +{ + if(value == NULL) + { + return true; + } + if(strlen(value) < 1 || value[0] == ' ' || strncmp(value, "NULL", 4) == 0) + { + return true; + } + return false; +} + static void freeRequestURIparam(void *data) { if(data != NULL) @@ -1098,12 +1111,19 @@ T2ERROR Profile_storeMarkerEvent(const char *profileName, T2Event *eventInfo) break; case MTYPE_ACCUMULATE: - T2Debug("Marker type is ACCUMULATE Event Value : %s\n", eventInfo->value); + { + const char *safeValue = (eventInfo->value != NULL) ? eventInfo->value : ""; + T2Debug("Marker type is ACCUMULATE Event Value : %s\n", safeValue); + if(!lookupEvent->reportEmptyParam && isEmptySubscriberValue(safeValue)) + { + T2Debug("Skipping empty/null subscribe marker value for %s\n", lookupEvent->markerName); + break; + } arraySize = Vector_Size(lookupEvent->u.accumulatedValues); T2Debug("Current array size : %d \n", arraySize); if( arraySize < MAX_ACCUMULATE) { - Vector_PushBack(lookupEvent->u.accumulatedValues, strdup(eventInfo->value)); + Vector_PushBack(lookupEvent->u.accumulatedValues, strdup(safeValue)); T2Debug("Sucessfully added value into vector New Size : %d\n", ++arraySize); if(lookupEvent->reportTimestampParam == REPORTTIMESTAMP_UNIXEPOCH) { @@ -1137,16 +1157,24 @@ T2ERROR Profile_storeMarkerEvent(const char *profileName, T2Event *eventInfo) T2Warning("Max size of the array has been reached Ignore New Value\n"); } break; + } case MTYPE_ABSOLUTE: default: + { + const char *safeValue = (eventInfo->value != NULL) ? eventInfo->value : ""; + if(!lookupEvent->reportEmptyParam && isEmptySubscriberValue(safeValue)) + { + T2Debug("Skipping empty/null subscribe marker value for %s\n", lookupEvent->markerName); + break; + } if(lookupEvent->u.markerValue) { free(lookupEvent->u.markerValue); lookupEvent->u.markerValue = NULL; } - lookupEvent->u.markerValue = strdup(eventInfo->value); + lookupEvent->u.markerValue = strdup(safeValue); T2Debug("New marker value saved : %s\n", lookupEvent->u.markerValue); if(lookupEvent->reportTimestampParam == REPORTTIMESTAMP_UNIXEPOCH) { @@ -1175,6 +1203,7 @@ T2ERROR Profile_storeMarkerEvent(const char *profileName, T2Event *eventInfo) } break; } + } pthread_mutex_unlock(&profile->eventMutex); } else @@ -2121,4 +2150,3 @@ unsigned int getMinThresholdDuration(char *profileName) return minThresholdDuration; } - diff --git a/source/bulkdata/profilexconf.c b/source/bulkdata/profilexconf.c index cda933f9..c2c1d874 100644 --- a/source/bulkdata/profilexconf.c +++ b/source/bulkdata/profilexconf.c @@ -57,6 +57,19 @@ static bool reportThreadExits = false; static bool isAbortTriggered = false ; static bool isOnDemandReport = false ; +static bool isEmptySubscriberValue(const char *value) +{ + if(value == NULL) + { + return true; + } + if(strlen(value) < 1 || value[0] == ' ' || strncmp(value, "NULL", 4) == 0) + { + return true; + } + return false; +} + #ifdef GTEST_ENABLE #define sendReportOverHTTP __wrap_sendReportOverHTTP #define sendCachedReportsOverHTTP __wrap_sendCachedReportsOverHTTP @@ -1112,12 +1125,19 @@ T2ERROR ProfileXConf_storeMarkerEvent(T2Event *eventInfo) break; case MTYPE_XCONF_ACCUMULATE: - T2Debug("Marker type is ACCUMULATE Event Value : %s\n", eventInfo->value); + { + const char *safeValue = (eventInfo->value != NULL) ? eventInfo->value : ""; + T2Debug("Marker type is ACCUMULATE Event Value : %s\n", safeValue); + if(!lookupEvent->reportEmptyParam && isEmptySubscriberValue(safeValue)) + { + T2Debug("Skipping empty/null subscribe marker value for %s\n", lookupEvent->markerName); + break; + } arraySize = Vector_Size(lookupEvent->u.accumulatedValues); T2Debug("Current array size : %d \n", arraySize); if( arraySize < MAX_ACCUMULATE) { - Vector_PushBack(lookupEvent->u.accumulatedValues, strdup(eventInfo->value)); + Vector_PushBack(lookupEvent->u.accumulatedValues, strdup(safeValue)); T2Debug("Sucessfully added value into vector New Size : %d\n", ++arraySize); } else if ( arraySize == MAX_ACCUMULATE ) @@ -1131,17 +1151,26 @@ T2ERROR ProfileXConf_storeMarkerEvent(T2Event *eventInfo) T2Warning("Max size of the array has been reached Ignore New Value\n"); } break; + } case MTYPE_XCONF_ABSOLUTE: default: + { + const char *safeValue = (eventInfo->value != NULL) ? eventInfo->value : ""; + if(!lookupEvent->reportEmptyParam && isEmptySubscriberValue(safeValue)) + { + T2Debug("Skipping empty/null subscribe marker value for %s\n", lookupEvent->markerName); + break; + } if(lookupEvent->u.markerValue) { free(lookupEvent->u.markerValue); } - lookupEvent->u.markerValue = strdup(eventInfo->value); + lookupEvent->u.markerValue = strdup(safeValue); T2Debug("New marker value saved : %s\n", lookupEvent->u.markerValue); break; } + } } else { diff --git a/source/reportgen/reportgen.c b/source/reportgen/reportgen.c index 4b5c325a..98834b1f 100644 --- a/source/reportgen/reportgen.c +++ b/source/reportgen/reportgen.c @@ -1567,6 +1567,13 @@ T2ERROR encodeEventMarkersInJSON(cJSON *valArray, Vector *eventMarkerList) default: if(eventMarker->u.markerValue != NULL) { + if(!eventMarker->reportEmptyParam && checkForEmptyString(eventMarker->u.markerValue)) + { + T2Debug("Skipping empty/\"NULL\" marker value for : %s\n", eventMarker->markerName); + free(eventMarker->u.markerValue); + eventMarker->u.markerValue = NULL; + break; + } arrayItem = cJSON_CreateObject(); if(arrayItem == NULL) {