From 9dc285d9c1f86c968893784b351325ceecbab055 Mon Sep 17 00:00:00 2001 From: dkumar798_comcast Date: Tue, 13 Jan 2026 11:29:15 +0000 Subject: [PATCH 01/28] Fix Coverity identified issues - dobby --- .../Common/include/ConditionVariable.h | 1 - .../Common/include/IDGenerator.h | 10 ++++- .../Common/source/ThreadedDispatcher.cpp | 39 +++++++++---------- .../source/sdbus/SDBusIpcService.cpp | 6 +-- AppInfrastructure/Public/Common/Notifier.h | 1 - .../ReadLine/source/ReadLine.cpp | 2 +- bundle/lib/source/DobbyBundleConfig.cpp | 4 ++ bundle/lib/source/DobbySpecConfig.cpp | 4 +- bundle/lib/source/DobbyTemplate.cpp | 4 +- bundle/tool/source/Main.cpp | 2 +- client/lib/source/DobbyProxy.cpp | 1 - client/tool/source/Main.cpp | 4 +- daemon/lib/source/Dobby.cpp | 24 ++++++------ daemon/lib/source/DobbyLogRelay.cpp | 4 +- daemon/lib/source/DobbyLogger.cpp | 2 +- daemon/lib/source/DobbyManager.cpp | 8 ++-- daemon/lib/source/DobbyStats.cpp | 2 +- daemon/lib/source/include/DobbyWorkQueue.h | 6 +-- daemon/process/source/Main.cpp | 2 +- ipcUtils/source/DobbyIpcBus.cpp | 1 - .../lib/include/DobbyRdkPluginUtils.h | 6 ++- .../lib/source/DobbyRdkPluginManager.cpp | 11 +++++- pluginLauncher/tool/source/Main.cpp | 1 + plugins/Common/source/ServiceMonitor.cpp | 3 -- plugins/EthanLog/client/cat/ethanlog-cat.cpp | 4 +- plugins/EthanLog/source/EthanLogLoop.cpp | 5 ++- .../source/MulticastSocketsPlugin.cpp | 6 +-- plugins/OpenCDM/source/OpenCDMPlugin.cpp | 11 ++++-- rdkPlugins/Minidump/source/AnonymousFile.cpp | 4 +- rdkPlugins/Networking/source/NetworkSetup.cpp | 20 ++++------ rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp | 7 +++- .../Storage/source/DynamicMountDetails.cpp | 7 +++- .../Storage/source/LoopMountDetails.cpp | 1 + rdkPlugins/Storage/source/RefCountFile.cpp | 7 ++++ utils/include/DobbyUtils.h | 2 +- utils/source/DobbyUtils.cpp | 2 + 36 files changed, 132 insertions(+), 92 deletions(-) diff --git a/AppInfrastructure/Common/include/ConditionVariable.h b/AppInfrastructure/Common/include/ConditionVariable.h index ef9d5b55d..470bf54f3 100644 --- a/AppInfrastructure/Common/include/ConditionVariable.h +++ b/AppInfrastructure/Common/include/ConditionVariable.h @@ -188,7 +188,6 @@ class ConditionVariable else { __ConditionVariableThrowOnError(err); - return std::cv_status::timeout; } } diff --git a/AppInfrastructure/Common/include/IDGenerator.h b/AppInfrastructure/Common/include/IDGenerator.h index 859ae7baa..28f7c0223 100644 --- a/AppInfrastructure/Common/include/IDGenerator.h +++ b/AppInfrastructure/Common/include/IDGenerator.h @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -85,10 +86,17 @@ class IDGenerator (N == 19) ? 0x4032F : (N == 20) ? 0x80534 : 0; +private: + static unsigned getRandomSeed() + { + std::random_device rd; + return rd(); + } + public: IDGenerator(unsigned offset = 0) : mOffset(offset) - , mLfsr(1 + (rand() % (mSize- 2))) + , mLfsr(1 + (getRandomSeed() % (mSize - 2))) { } public: diff --git a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp index 2c62e8312..10edd941e 100644 --- a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp +++ b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp @@ -44,7 +44,6 @@ void ThreadedDispatcher::post(std::function work) if(running) { q.push_back(work); - lock.unlock(); cv.notify_one(); } else @@ -74,7 +73,6 @@ void syncCallback(std::mutex* lock, std::condition_variable* cond, bool* fired) std::unique_lock locker(*lock); *fired = true; cond->notify_all(); - locker.unlock(); } } // namespace /** @@ -117,7 +115,6 @@ void ThreadedDispatcher::sync() } // Add the work object to the queue which takes the lock and sets 'fired' to true q.push_back(std::bind(syncCallback, &lock, &cond, &fired)); - qlocker.unlock(); cv.notify_one(); // Wait for 'fired' to become true std::unique_lock locker(lock); @@ -126,30 +123,33 @@ void ThreadedDispatcher::sync() cond.wait(locker); } } -namespace -{ -void unlockAndSetFlagToFalse(std::mutex& m, bool& flag) -{ - using namespace std; - m.unlock(); - flag = false; -} -} + /** * @brief Perform any work remaining in the queue, then stop accepting new work. */ void ThreadedDispatcher::flush() { //To ensure all the work that is in the queue is done, we lock a mutex. - //post a job to the queue that unlocks it and stops running further jobs. + //post a job to the queue that signals completion via condition variable. //Then block here until that's done. if(running) { - std::mutex m2; - m2.lock(); - post(bind(unlockAndSetFlagToFalse, std::ref(m2), std::ref(this->running))); - m2.lock(); - m2.unlock(); + std::mutex flushMutex; + std::condition_variable flushCond; + bool flushed = false; + + std::unique_lock locker(flushMutex); + post([&]() { + std::lock_guard lock(flushMutex); + flushed = true; + running = false; + flushCond.notify_one(); + }); + + while (!flushed) { + flushCond.wait(locker); + } + stop(); } else @@ -164,7 +164,6 @@ void ThreadedDispatcher::stop() { std::unique_lock lock(m); running = false; - lock.unlock(); cv.notify_one(); t.join(); } @@ -214,4 +213,4 @@ std::function ThreadedDispatcher::next() q.pop_front(); return work; } -} //AICommon \ No newline at end of file +} //AICommon diff --git a/AppInfrastructure/IpcService/source/sdbus/SDBusIpcService.cpp b/AppInfrastructure/IpcService/source/sdbus/SDBusIpcService.cpp index 237597967..54c9e82ab 100644 --- a/AppInfrastructure/IpcService/source/sdbus/SDBusIpcService.cpp +++ b/AppInfrastructure/IpcService/source/sdbus/SDBusIpcService.cpp @@ -223,7 +223,7 @@ bool SDBusIpcService::init(const std::string &serviceName, if (defaultTimeoutMs <= 0) mDefaultTimeoutUsecs = (25 * 1000 * 1000); else - mDefaultTimeoutUsecs = (defaultTimeoutMs * 1000); + mDefaultTimeoutUsecs = (static_cast(defaultTimeoutMs) * 1000); // eventfd used to wake the poll loop @@ -426,7 +426,7 @@ std::shared_ptr SDBusIpcService::invokeMethod(const Method &m if (timeoutMs < 0) timeoutUsecs = mDefaultTimeoutUsecs; else - timeoutUsecs = (timeoutMs * 1000); + timeoutUsecs = (static_cast(timeoutMs) * 1000); // create the reply getter std::shared_ptr replyGetter = @@ -504,7 +504,7 @@ bool SDBusIpcService::invokeMethod(const Method &method, if (timeoutMs < 0) timeoutUsecs = mDefaultTimeoutUsecs; else - timeoutUsecs = (timeoutMs * 1000); + timeoutUsecs = (static_cast(timeoutMs) * 1000); // clear the reply args list replyArgs.clear(); diff --git a/AppInfrastructure/Public/Common/Notifier.h b/AppInfrastructure/Public/Common/Notifier.h index 7eae1d512..a4c64ae3c 100644 --- a/AppInfrastructure/Public/Common/Notifier.h +++ b/AppInfrastructure/Public/Common/Notifier.h @@ -195,7 +195,6 @@ class Notifier : virtual public Polymorphic { cv.notify_all(); } - lock.unlock(); } protected: diff --git a/AppInfrastructure/ReadLine/source/ReadLine.cpp b/AppInfrastructure/ReadLine/source/ReadLine.cpp index 084d5741d..7feb6d9f6 100644 --- a/AppInfrastructure/ReadLine/source/ReadLine.cpp +++ b/AppInfrastructure/ReadLine/source/ReadLine.cpp @@ -438,7 +438,7 @@ void ReadLine::commandExecute(const std::string& cmdStr, } else if (!errStr.empty()) { - fprintf(stderr, "Ambiguous command '\%s', possible commands: %s %s\n", + fprintf(stderr, "Ambiguous command '%s', possible commands: %s %s\n", cmdStr.c_str(), cmdRef->name.c_str(), errStr.c_str()); } else if (cmdRef->handler != nullptr) diff --git a/bundle/lib/source/DobbyBundleConfig.cpp b/bundle/lib/source/DobbyBundleConfig.cpp index ea6662cd3..26c65b7d6 100644 --- a/bundle/lib/source/DobbyBundleConfig.cpp +++ b/bundle/lib/source/DobbyBundleConfig.cpp @@ -164,11 +164,13 @@ bool DobbyBundleConfig::isValid() const uid_t DobbyBundleConfig::userId() const { + std::lock_guard locker(mLock); return mUserId; } gid_t DobbyBundleConfig::groupId() const { + std::lock_guard locker(mLock); return mGroupId; } @@ -244,6 +246,7 @@ const std::string& DobbyBundleConfig::rootfsPath() const bool DobbyBundleConfig::restartOnCrash() const { + std::lock_guard locker(mLock); return mRestartOnCrash; } @@ -286,6 +289,7 @@ const std::map& DobbyBundleConfig::legacyPlugins() con const std::map& DobbyBundleConfig::rdkPlugins() const { + std::lock_guard locker(mLock); return mRdkPlugins; } diff --git a/bundle/lib/source/DobbySpecConfig.cpp b/bundle/lib/source/DobbySpecConfig.cpp index 326d428a3..1cb6627db 100644 --- a/bundle/lib/source/DobbySpecConfig.cpp +++ b/bundle/lib/source/DobbySpecConfig.cpp @@ -917,8 +917,8 @@ bool DobbySpecConfig::processUserNs(const Json::Value& value, bool DobbySpecConfig::processRtPriority(const Json::Value& value, ctemplate::TemplateDictionary* dictionary) { - int rtPriorityDefault; - int rtPriorityLimit; + int rtPriorityDefault = 0; + int rtPriorityLimit = 0; if (mSpecVersion == SpecVersion::Version1_0) { diff --git a/bundle/lib/source/DobbyTemplate.cpp b/bundle/lib/source/DobbyTemplate.cpp index bfe80ca4c..32cb84184 100644 --- a/bundle/lib/source/DobbyTemplate.cpp +++ b/bundle/lib/source/DobbyTemplate.cpp @@ -536,7 +536,7 @@ std::string DobbyTemplate::_apply(const ctemplate::TemplateDictionaryInterface* if (!mTemplateCache->ExpandNoLoad(mTemplateKey, prettyPrint ? ctemplate::STRIP_WHITESPACE - : ctemplate::STRIP_WHITESPACE, + : ctemplate::DO_NOT_STRIP, dictionary, nullptr, &result)) { AI_LOG_ERROR("template cache expand on load failed"); @@ -654,7 +654,7 @@ bool DobbyTemplate::_applyAt(int dirFd, const std::string& fileName, bool success = mTemplateCache->ExpandNoLoad(mTemplateKey, prettyPrint ? ctemplate::STRIP_WHITESPACE : - ctemplate::STRIP_WHITESPACE, + ctemplate::DO_NOT_STRIP, dictionary, nullptr, &emitter); if (!success) { diff --git a/bundle/tool/source/Main.cpp b/bundle/tool/source/Main.cpp index f6f13bc00..49d475aa8 100644 --- a/bundle/tool/source/Main.cpp +++ b/bundle/tool/source/Main.cpp @@ -113,7 +113,7 @@ static void parseArgs(const int argc, char **argv) fprintf(stderr, "Warning: Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Warning: Unknown option character `\\x%x'.\n", optopt); - + /* fall through */ default: exit(EXIT_FAILURE); break; diff --git a/client/lib/source/DobbyProxy.cpp b/client/lib/source/DobbyProxy.cpp index 26e96e14e..9fbb6f67d 100644 --- a/client/lib/source/DobbyProxy.cpp +++ b/client/lib/source/DobbyProxy.cpp @@ -136,7 +136,6 @@ DobbyProxy::~DobbyProxy() { std::unique_lock locker(mStateChangeLock); mStateChangeQueue.emplace_back(StateChangeEvent::Terminate); - locker.unlock(); mStateChangeCond.notify_all(); mStateChangeThread.join(); diff --git a/client/tool/source/Main.cpp b/client/tool/source/Main.cpp index 1f9439e14..a2afded68 100644 --- a/client/tool/source/Main.cpp +++ b/client/tool/source/Main.cpp @@ -100,6 +100,7 @@ void containerStopCallback(int32_t cd, const std::string &containerId, if (state == IDobbyProxyEvents::ContainerState::Stopped && containerId == *id) { AI_LOG_INFO("Container %s has stopped", containerId.c_str()); + std::lock_guard locker(gLock); promise.set_value(); } } @@ -119,6 +120,7 @@ void containerWaitCallback(int32_t cd, const std::string &containerId, if (state == wp->state && containerId == wp->containerId) { AI_LOG_INFO("Wait complete"); + std::lock_guard locker(gLock); promise.set_value(); } } @@ -1552,7 +1554,7 @@ static void parseArgs(const int argc, char **argv) fprintf(stderr, "Warning: Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Warning: Unknown option character `\\x%x'.\n", optopt); - + /* fall through */ default: exit(EXIT_FAILURE); break; diff --git a/daemon/lib/source/Dobby.cpp b/daemon/lib/source/Dobby.cpp index 9d526124e..2188ac605 100644 --- a/daemon/lib/source/Dobby.cpp +++ b/daemon/lib/source/Dobby.cpp @@ -385,10 +385,6 @@ void Dobby::logJournaldPrinter(int level, const char *file, const char *func, case AI_DEBUG_LEVEL_DEBUG: logLevel = "DBG: "; break; - default: - AI_LOG_WARN("Unknown debug level: %d", level); - logLevel = ": "; - break; } sd_journal_send("SYSLOG_IDENTIFIER=DobbyDaemon", @@ -719,7 +715,7 @@ void Dobby::ping(std::shared_ptr replySender) // If running as systemd service then also use this to wag the dog #if defined(RDK) && defined(USE_SYSTEMD) - mWorkQueue->postWork( + if (!mWorkQueue->postWork( [this]() { if (mWatchdogTimerId >= 0) @@ -730,8 +726,10 @@ void Dobby::ping(std::shared_ptr replySender) AI_LOG_SYS_ERROR(-ret, "failed to send watchdog notification"); } } - } - ); + })) + { + AI_LOG_WARN("failed to queue watchdog notification work"); + } #endif AI_LOG_FN_EXIT(); @@ -1999,8 +1997,10 @@ void Dobby::createBundle(std::shared_ptr replySender) // Try and get container stats bool result = manager->createBundle(id, spec); - // Fire off the reply - replySender->sendReply({ result }); + if (!replySender->sendReply({ result })) + { + AI_LOG_ERROR("failed to send createBundle reply"); + } }; // Queue the work, if successful then we're done @@ -2050,8 +2050,10 @@ void Dobby::getSpec(std::shared_ptr replySender) // Get the container spec std::string spec = manager->specOfContainer(descriptor); - // Fire off the reply - replySender->sendReply({ spec }); + if (!replySender->sendReply({ spec })) + { + AI_LOG_ERROR("failed to send getSpec reply"); + } }; // Queue the work, if successful then we're done diff --git a/daemon/lib/source/DobbyLogRelay.cpp b/daemon/lib/source/DobbyLogRelay.cpp index a0161cf3c..aa0647811 100644 --- a/daemon/lib/source/DobbyLogRelay.cpp +++ b/daemon/lib/source/DobbyLogRelay.cpp @@ -64,7 +64,7 @@ DobbyLogRelay::DobbyLogRelay(const std::string &sourceSocketPath, mDestinationSocketAddress = {}; mDestinationSocketAddress.sun_family = AF_UNIX; - strcpy(mDestinationSocketAddress.sun_path, mDestinationSocketPath.c_str()); + strncpy(mDestinationSocketAddress.sun_path, mDestinationSocketPath.c_str(), sizeof(mDestinationSocketAddress.sun_path) - 1); AI_LOG_INFO("Created log relay from %s to %s", mSourceSocketPath.c_str(), mDestinationSocketPath.c_str()); } @@ -196,7 +196,7 @@ int DobbyLogRelay::createDgramSocket(const std::string &path) struct sockaddr_un address = {}; address.sun_family = AF_UNIX; - strcpy(address.sun_path, path.c_str()); + strncpy(address.sun_path, path.c_str(), sizeof(address.sun_path) - 1); if (bind(sockFd, (const struct sockaddr *)&address, sizeof(address)) < 0) { diff --git a/daemon/lib/source/DobbyLogger.cpp b/daemon/lib/source/DobbyLogger.cpp index 4db0ed01c..6ea9e1540 100644 --- a/daemon/lib/source/DobbyLogger.cpp +++ b/daemon/lib/source/DobbyLogger.cpp @@ -142,7 +142,7 @@ int DobbyLogger::createUnixSocket(const std::string path) // Set properties on the socket struct sockaddr_un address = {}; address.sun_family = AF_UNIX; - strcpy(address.sun_path, path.c_str()); + strncpy(address.sun_path, path.c_str(), sizeof(address.sun_path) - 1); // Attempt to bind the socket if (TEMP_FAILURE_RETRY(bind(sockFd, (const struct sockaddr *)&address, sizeof(address))) < 0) diff --git a/daemon/lib/source/DobbyManager.cpp b/daemon/lib/source/DobbyManager.cpp index cec6a5b3a..2e47c9b51 100644 --- a/daemon/lib/source/DobbyManager.cpp +++ b/daemon/lib/source/DobbyManager.cpp @@ -503,9 +503,10 @@ void DobbyManager::cleanupContainersShutdown() // container must be in uninterrable sleep and we cannot do anything // Remove it container from the list (even though it wasn't clean up) // to avoid repeating indefinitely. It will be cleaned on boot-up + std::string containerId = it->first.c_str(); it = mContainers.erase(it); - AI_LOG_ERROR("Failed to stop container %s. Will attempt to clean up at daemon restart", it->first.c_str()); - } + AI_LOG_ERROR("Failed to stop container %s. Will attempt to clean up at daemon restart", containerId.c_str()); + } else { // This would normally be done async by the runc monitor thread, but we're @@ -1656,7 +1657,7 @@ bool DobbyManager::hibernateContainer(int32_t cd, const std::string& options) uint32_t pid = pidIt->asUInt(); ret = DobbyHibernate::HibernateProcess(pid, DobbyHibernate::DFL_TIMEOUTE_MS, - DobbyHibernate::DFL_LOCATOR, std::move(dest), compress); + DobbyHibernate::DFL_LOCATOR, dest, compress); if (ret != DobbyHibernate::Error::ErrorNone) { AI_LOG_WARN("Error hibernating pid: '%d'", pid); @@ -3404,6 +3405,7 @@ bool DobbyManager::invalidContainerCleanupTask() // Pid is still valid. Attempt to send SIGKILL mRunc->killCont(it->first, SIGKILL, true); + // Note: This sleep is in a cleanup task that runs periodically, holding lock briefly is acceptable // Did we actually kill it? Give it some time, then check the status std::this_thread::sleep_for(std::chrono::milliseconds(200)); DobbyRunC::ContainerStatus state = mRunc->state(it->first); diff --git a/daemon/lib/source/DobbyStats.cpp b/daemon/lib/source/DobbyStats.cpp index 9b77e84c2..37d3f72a6 100644 --- a/daemon/lib/source/DobbyStats.cpp +++ b/daemon/lib/source/DobbyStats.cpp @@ -445,7 +445,7 @@ Json::Value DobbyStats::getProcessTree(const ContainerId& id, { if (pid > std::numeric_limits::max() || pid < 0) { - AI_LOG_WARN("Invalid PID found: %ld", pid); + AI_LOG_WARN("Invalid PID found: %lld", static_cast(pid)); continue; } diff --git a/daemon/lib/source/include/DobbyWorkQueue.h b/daemon/lib/source/include/DobbyWorkQueue.h index 607bba0c7..5b53b4c88 100644 --- a/daemon/lib/source/include/DobbyWorkQueue.h +++ b/daemon/lib/source/include/DobbyWorkQueue.h @@ -62,9 +62,9 @@ class DobbyWorkQueue { } }; - uint64_t mWorkCounter; + std::atomic mWorkCounter; - bool mExitRequested; + std::atomic mExitRequested; std::atomic mRunningThreadId; AICommon::Mutex mWorkQueueLock; @@ -73,7 +73,7 @@ class DobbyWorkQueue AICommon::Mutex mWorkCompleteLock; AICommon::ConditionVariable mWorkCompleteCond; - uint64_t mWorkCompleteCounter; + std::atomic mWorkCompleteCounter; }; diff --git a/daemon/process/source/Main.cpp b/daemon/process/source/Main.cpp index 84569e679..0daee98b3 100644 --- a/daemon/process/source/Main.cpp +++ b/daemon/process/source/Main.cpp @@ -230,7 +230,7 @@ static void parseArgs(int argc, char **argv) fprintf(stderr, "Warning: Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Warning: Unknown option character `\\x%x'.\n", optopt); - + /* fall through */ default: exit(EXIT_FAILURE); break; diff --git a/ipcUtils/source/DobbyIpcBus.cpp b/ipcUtils/source/DobbyIpcBus.cpp index 093a3ec4b..d7dedc464 100644 --- a/ipcUtils/source/DobbyIpcBus.cpp +++ b/ipcUtils/source/DobbyIpcBus.cpp @@ -63,7 +63,6 @@ DobbyIpcBus::~DobbyIpcBus() { std::unique_lock locker(mLock); mServiceChangeQueue.emplace_back(ServiceChangeEvent::Terminate); - locker.unlock(); mServiceChangeCond.notify_all(); mServiceChangeThread.join(); diff --git a/pluginLauncher/lib/include/DobbyRdkPluginUtils.h b/pluginLauncher/lib/include/DobbyRdkPluginUtils.h index e1fdb54de..226fb759f 100644 --- a/pluginLauncher/lib/include/DobbyRdkPluginUtils.h +++ b/pluginLauncher/lib/include/DobbyRdkPluginUtils.h @@ -160,7 +160,11 @@ class DobbyRdkPluginUtils bool addAnnotation(const std::string &key, const std::string &value); bool removeAnnotation(const std::string &key); - std::map getAnnotations() const { return mAnnotations; }; + std::map getAnnotations() const + { + std::lock_guard locker(mLock); + return mAnnotations; + } int exitStatus; diff --git a/pluginLauncher/lib/source/DobbyRdkPluginManager.cpp b/pluginLauncher/lib/source/DobbyRdkPluginManager.cpp index 2014b81d8..ec33fa6e7 100644 --- a/pluginLauncher/lib/source/DobbyRdkPluginManager.cpp +++ b/pluginLauncher/lib/source/DobbyRdkPluginManager.cpp @@ -170,10 +170,17 @@ bool DobbyRdkPluginManager::loadPlugins() } int directoriesCount = 0; - struct dirent **namelist; + struct dirent **namelist = nullptr; // Need to sort directories with versionsort so lib.12 would be greater than lib.2 directoriesCount = scandir(mPluginPath.c_str(), &namelist, 0, versionsort); + if (directoriesCount < 0) + { + AI_LOG_SYS_ERROR(errno, "failed to scan directory '%s'", mPluginPath.c_str()); + closedir(dir); + return false; + } + for(int i=0; i locker(mLock); + mClients.clear(); + } // free the event loop sd_event_unref(loop); diff --git a/plugins/MulticastSockets/source/MulticastSocketsPlugin.cpp b/plugins/MulticastSockets/source/MulticastSocketsPlugin.cpp index 07464a0fe..1afbca39f 100644 --- a/plugins/MulticastSockets/source/MulticastSocketsPlugin.cpp +++ b/plugins/MulticastSockets/source/MulticastSocketsPlugin.cpp @@ -109,7 +109,7 @@ bool MulticastSocketPlugin::postConstruction(const ContainerId &id, int duppedSocket = startupState->addFileDescriptor(mName, socket); close(socket); //close original fd, it's already dupped and stored in startupState - if (duppedSocket == -1) + if (duppedSocket < 0) { AI_LOG_ERROR("Failed to duplicate server socket for container %s", id.c_str()); return false; @@ -130,7 +130,7 @@ bool MulticastSocketPlugin::postConstruction(const ContainerId &id, int duppedSocket = startupState->addFileDescriptor(mName, socket); close(socket); //close original fd, it's already dupped and stored in startupState - if (duppedSocket == -1) + if (duppedSocket < 0) { AI_LOG_ERROR("Failed to duplicate server socket for container %s", id.c_str()); return false; @@ -212,7 +212,7 @@ std::vector MulticastSocketPlugin::parse multicastSocket.portNumber = static_cast(port.asInt()); multicastSocket.name = name.asString(); - socketsVec.push_back(multicastSocket); + socketsVec.push_back(std::move(multicastSocket)); } return socketsVec; diff --git a/plugins/OpenCDM/source/OpenCDMPlugin.cpp b/plugins/OpenCDM/source/OpenCDMPlugin.cpp index 5d9e7069b..13a45b105 100644 --- a/plugins/OpenCDM/source/OpenCDMPlugin.cpp +++ b/plugins/OpenCDM/source/OpenCDMPlugin.cpp @@ -200,10 +200,13 @@ bool OpenCDMPlugin::enableTmpOCDMDir(const std::shared_ptr& st return false; } - // can now add to the bind mount list - startupState->addMount(dirPath, dirPath, "bind", - (MS_BIND | MS_NOSUID | MS_NODEV | MS_NOEXEC)); - return true; + if (!startupState->addMount(dirPath, dirPath, "bind", + (MS_BIND | MS_NOSUID | MS_NODEV | MS_NOEXEC))) + { + AI_LOG_ERROR("failed to add bind mount for OCDM directory '%s'", dirPath.c_str()); + return false; + } + return true; } // ----------------------------------------------------------------------------- diff --git a/rdkPlugins/Minidump/source/AnonymousFile.cpp b/rdkPlugins/Minidump/source/AnonymousFile.cpp index 85d259874..d169cbf04 100644 --- a/rdkPlugins/Minidump/source/AnonymousFile.cpp +++ b/rdkPlugins/Minidump/source/AnonymousFile.cpp @@ -130,9 +130,9 @@ bool AnonymousFile::copyContentTo(const std::string& destFile) } long fileSize = getFileSize(fp); - if (!fileSize) + if (fileSize <= 0) { - AI_LOG_DEBUG("Empty file for fd %d", mFd); + AI_LOG_DEBUG("Empty or invalid file size %ld for fd %d", fileSize, mFd); fclose(fp); fp = nullptr; AI_LOG_FN_EXIT(); diff --git a/rdkPlugins/Networking/source/NetworkSetup.cpp b/rdkPlugins/Networking/source/NetworkSetup.cpp index baa4cd346..4dcd2263d 100644 --- a/rdkPlugins/Networking/source/NetworkSetup.cpp +++ b/rdkPlugins/Networking/source/NetworkSetup.cpp @@ -190,10 +190,9 @@ std::vector constructBridgeRules(const std::shared_ptrsecond.emplace_front("DobbyInputChain -p ICMPv6 -j ACCEPT"); + appendRuleSet[Netfilter::TableType::Filter].emplace_front("DobbyInputChain -p ICMPv6 -j ACCEPT"); } // add addresses to rules depending on ipVersion @@ -201,27 +200,24 @@ std::vector constructBridgeRules(const std::shared_ptrsecond.emplace_front("POSTROUTING -s %y -d 255.255.255.255/32 ! -o " BRIDGE_NAME " -j RETURN"); - appendNatRules->second.emplace_front("POSTROUTING -s %y -d 224.0.0.0/24 ! -o " BRIDGE_NAME " -j RETURN"); + appendRuleSet[Netfilter::TableType::Nat].emplace_front("POSTROUTING -s %y -d 255.255.255.255/32 ! -o " BRIDGE_NAME " -j RETURN"); + appendRuleSet[Netfilter::TableType::Nat].emplace_front("POSTROUTING -s %y -d 224.0.0.0/24 ! -o " BRIDGE_NAME " -j RETURN"); // reject with "icmp-port-unreachable" if not ACCEPTed by now - Netfilter::RuleSet::iterator appendFilterRules = appendRuleSet.find(Netfilter::TableType::Filter); - appendFilterRules->second.emplace_back("FORWARD -o " BRIDGE_NAME " -j REJECT --reject-with icmp-port-unreachable"); - appendFilterRules->second.emplace_back("FORWARD -i " BRIDGE_NAME " -j REJECT --reject-with icmp-port-unreachable"); + appendRuleSet[Netfilter::TableType::Filter].emplace_back("FORWARD -o " BRIDGE_NAME " -j REJECT --reject-with icmp-port-unreachable"); + appendRuleSet[Netfilter::TableType::Filter].emplace_back("FORWARD -i " BRIDGE_NAME " -j REJECT --reject-with icmp-port-unreachable"); bridgeAddressRange = BRIDGE_ADDRESS_RANGE "/24"; } else if (ipVersion == AF_INET6) { - Netfilter::RuleSet::iterator appendFilterRules = appendRuleSet.find(Netfilter::TableType::Filter); // add DobbyInputChain rule to accept solicited-node multicast requests from containers - appendFilterRules->second.emplace_front("DobbyInputChain -s %y -d ff02::1:ff40:b01/128 -i " BRIDGE_NAME " -j ACCEPT"); + appendRuleSet[Netfilter::TableType::Filter].emplace_front("DobbyInputChain -s %y -d ff02::1:ff40:b01/128 -i " BRIDGE_NAME " -j ACCEPT"); // reject with "icmp6-port-unreachable" if not ACCEPTed by now - appendFilterRules->second.emplace_back("FORWARD -o " BRIDGE_NAME " -j REJECT --reject-with icmp6-port-unreachable"); - appendFilterRules->second.emplace_back("FORWARD -i " BRIDGE_NAME " -j REJECT --reject-with icmp6-port-unreachable"); + appendRuleSet[Netfilter::TableType::Filter].emplace_back("FORWARD -o " BRIDGE_NAME " -j REJECT --reject-with icmp6-port-unreachable"); + appendRuleSet[Netfilter::TableType::Filter].emplace_back("FORWARD -i " BRIDGE_NAME " -j REJECT --reject-with icmp6-port-unreachable"); bridgeAddressRange = BRIDGE_ADDRESS_RANGE_IPV6 "/120"; } diff --git a/rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp b/rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp index ee3c1d189..6d0bc5a46 100644 --- a/rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp +++ b/rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp @@ -258,8 +258,11 @@ void OOMCrash::createFileForOOM() if (errno != ENOENT) AI_LOG_ERROR("failed to open '%s' (%d - %s)", path.c_str(), errno, strerror(errno)); } - AI_LOG_INFO("%s file created",memoryExceedFile.c_str()); - fclose(fp); + else + { + AI_LOG_INFO("%s file created",memoryExceedFile.c_str()); + fclose(fp); + } } else { diff --git a/rdkPlugins/Storage/source/DynamicMountDetails.cpp b/rdkPlugins/Storage/source/DynamicMountDetails.cpp index 84a7bf78f..8c7f6f529 100644 --- a/rdkPlugins/Storage/source/DynamicMountDetails.cpp +++ b/rdkPlugins/Storage/source/DynamicMountDetails.cpp @@ -166,9 +166,12 @@ bool DynamicMountDetails::onCreateContainer() const // Creating the file first ensures an inode exists for the // bind mount to target. int fd = open(targetPath.c_str(), O_RDONLY | O_CREAT, 0644); - if ((fd == 0) || (errno == EEXIST)) + if ((fd >= 0) || (errno == EEXIST)) { - close(fd); + if (fd >= 0) + { + close(fd); + } success = true; } else diff --git a/rdkPlugins/Storage/source/LoopMountDetails.cpp b/rdkPlugins/Storage/source/LoopMountDetails.cpp index bd59dac02..f92ab3295 100644 --- a/rdkPlugins/Storage/source/LoopMountDetails.cpp +++ b/rdkPlugins/Storage/source/LoopMountDetails.cpp @@ -123,6 +123,7 @@ bool LoopMountDetails::onPreCreate() AI_LOG_SYS_ERROR(errno, "failed to close loop device dir"); return false; } + loopDevFd = -1; // Prevent double close } // Reset the reference count if it isn't 0 (shouldn't happen) diff --git a/rdkPlugins/Storage/source/RefCountFile.cpp b/rdkPlugins/Storage/source/RefCountFile.cpp index 57a1e860a..5decaeec2 100644 --- a/rdkPlugins/Storage/source/RefCountFile.cpp +++ b/rdkPlugins/Storage/source/RefCountFile.cpp @@ -24,6 +24,7 @@ #include #include #include +#include RefCountFile::RefCountFile(std::string file): mFilePath(std::move(file)), mFd(-1), mOpen(false) { @@ -110,6 +111,12 @@ int RefCountFile::Increment() if (ref >= 0) { + if (ref == INT_MAX) + { + AI_LOG_ERROR("Reference count overflow at INT_MAX"); + AI_LOG_FN_EXIT(); + return -1; + } ref = Write(++ref); AI_LOG_DEBUG("ref count: %d", ref); } diff --git a/utils/include/DobbyUtils.h b/utils/include/DobbyUtils.h index bade81209..18dc65919 100644 --- a/utils/include/DobbyUtils.h +++ b/utils/include/DobbyUtils.h @@ -155,7 +155,7 @@ class DobbyUtils : public virtual IDobbyUtils gid_t getGID(pid_t pid) const override; private: - std::mutex mMetaDataLock; + mutable std::mutex mMetaDataLock; std::map, int> mIntegerMetaData; std::map, std::string> mStringMetaData; diff --git a/utils/source/DobbyUtils.cpp b/utils/source/DobbyUtils.cpp index f874290f8..becbd4e94 100644 --- a/utils/source/DobbyUtils.cpp +++ b/utils/source/DobbyUtils.cpp @@ -1546,6 +1546,7 @@ int DobbyUtils::getIntegerMetaData(const ContainerId &id, const std::string &key, int defaultValue) const { + std::lock_guard locker(mMetaDataLock); auto it = mIntegerMetaData.find(std::make_pair(id, key)); if (it == mIntegerMetaData.end()) return defaultValue; @@ -1574,6 +1575,7 @@ std::string DobbyUtils::getStringMetaData(const ContainerId &id, const std::string &key, const std::string &defaultValue) const { + std::lock_guard locker(mMetaDataLock); auto it = mStringMetaData.find(std::make_pair(id, key)); if (it == mStringMetaData.end()) return defaultValue; From bb782fd3501180e28141be2e43cc001aa14423ab Mon Sep 17 00:00:00 2001 From: dkumar798_comcast Date: Wed, 21 Jan 2026 10:03:35 +0000 Subject: [PATCH 02/28] RDKEMW-12282: Fix Coverity identified issues - dobby --- .../Common/source/ThreadedDispatcher.cpp | 3 + AppInfrastructure/Common/source/Timer.cpp | 5 +- bundle/lib/source/DobbyConfig.cpp | 1 + bundle/lib/source/DobbyTemplate.cpp | 3 +- bundle/tool/source/Main.cpp | 98 ++++----- client/tool/source/Main.cpp | 1 - daemon/lib/source/DobbyContainer.cpp | 2 + daemon/lib/source/DobbyLogRelay.cpp | 2 + daemon/lib/source/DobbyLogger.cpp | 44 ++-- daemon/lib/source/DobbyManager.cpp | 4 +- daemon/lib/source/DobbyWorkQueue.cpp | 1 + daemon/process/source/Main.cpp | 189 +++++++++--------- .../lib/source/DobbyRdkPluginManager.cpp | 1 - .../lib/source/DobbyRdkPluginUtils.cpp | 12 +- pluginLauncher/tool/source/Main.cpp | 1 - plugins/EthanLog/client/cat/ethanlog-cat.cpp | 3 +- plugins/EthanLog/source/EthanLogClient.cpp | 3 +- .../source/MulticastSocketsPlugin.cpp | 16 +- .../source/AppServicesRdkPlugin.cpp | 3 +- .../HttpProxy/source/HttpProxyPlugin.cpp | 3 +- .../IONMemory/source/IonMemoryPlugin.cpp | 3 +- rdkPlugins/Logging/source/FileSink.cpp | 3 +- .../Networking/source/NetworkingPlugin.cpp | 1 + .../Storage/source/DynamicMountDetails.cpp | 13 +- settings/source/Settings.cpp | 1 + 25 files changed, 228 insertions(+), 188 deletions(-) diff --git a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp index 10edd941e..7666d4313 100644 --- a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp +++ b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp @@ -132,8 +132,10 @@ void ThreadedDispatcher::flush() //To ensure all the work that is in the queue is done, we lock a mutex. //post a job to the queue that signals completion via condition variable. //Then block here until that's done. + std::unique_lock runningLocker(m); if(running) { + runningLocker.unlock(); std::mutex flushMutex; std::condition_variable flushCond; bool flushed = false; @@ -154,6 +156,7 @@ void ThreadedDispatcher::flush() } else { + runningLocker.unlock(); AI_LOG_WARN("This dispatcher is no longer running. Ignoring flush request."); } } diff --git a/AppInfrastructure/Common/source/Timer.cpp b/AppInfrastructure/Common/source/Timer.cpp index 9fcc8bb73..faff2afad 100644 --- a/AppInfrastructure/Common/source/Timer.cpp +++ b/AppInfrastructure/Common/source/Timer.cpp @@ -32,7 +32,10 @@ using namespace AICommon; Timer::~Timer() { - cancel(); + try { + cancel(); + } catch (const std::exception& e) { + } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/bundle/lib/source/DobbyConfig.cpp b/bundle/lib/source/DobbyConfig.cpp index 0fe8441ec..2fe6d47f7 100644 --- a/bundle/lib/source/DobbyConfig.cpp +++ b/bundle/lib/source/DobbyConfig.cpp @@ -320,6 +320,7 @@ bool DobbyConfig::changeProcessArgs(const std::string& command) */ void DobbyConfig::printCommand() const { + std::lock_guard locker(mLock); std::shared_ptr cfg = config(); if (cfg == nullptr) { diff --git a/bundle/lib/source/DobbyTemplate.cpp b/bundle/lib/source/DobbyTemplate.cpp index 32cb84184..8e7b7499c 100644 --- a/bundle/lib/source/DobbyTemplate.cpp +++ b/bundle/lib/source/DobbyTemplate.cpp @@ -124,9 +124,10 @@ DobbyTemplate* DobbyTemplate::instance() } } + DobbyTemplate* result = mInstance; pthread_rwlock_unlock(&mInstanceLock); - return mInstance; + return result; } // ----------------------------------------------------------------------------- diff --git a/bundle/tool/source/Main.cpp b/bundle/tool/source/Main.cpp index 49d475aa8..c9f3a1848 100644 --- a/bundle/tool/source/Main.cpp +++ b/bundle/tool/source/Main.cpp @@ -113,7 +113,6 @@ static void parseArgs(const int argc, char **argv) fprintf(stderr, "Warning: Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Warning: Unknown option character `\\x%x'.\n", optopt); - /* fall through */ default: exit(EXIT_FAILURE); break; @@ -228,57 +227,62 @@ static bool generateOciBundle(std::shared_ptr settings, */ int main(int argc, char *argv[]) { - printf("Dobby Bundle Generator Tool\n"); - parseArgs(argc, argv); + try { + printf("Dobby Bundle Generator Tool\n"); + parseArgs(argc, argv); - // Set up so we can read commands - auto readLine = IReadLine::create(); - if (!readLine || !readLine->isValid()) - { - AI_LOG_ERROR_EXIT("failed to create ReadLine object"); - exit(EXIT_FAILURE); - } + // Set up so we can read commands + auto readLine = IReadLine::create(); + if (!readLine || !readLine->isValid()) + { + AI_LOG_ERROR_EXIT("failed to create ReadLine object"); + exit(EXIT_FAILURE); + } - // Can't do any work without a file to process or somewhere to put the - // output - if (inputPath.empty()) - { - AI_LOG_ERROR("Must provide a Dobby spec as an input"); - exit(EXIT_FAILURE); - } - else if (access(inputPath.c_str(), R_OK) != 0) - { - AI_LOG_ERROR("Cannot access Dobby spec file %s", inputPath.c_str()); - exit(EXIT_FAILURE); - } + // Can't do any work without a file to process or somewhere to put the + // output + if (inputPath.empty()) + { + AI_LOG_ERROR("Must provide a Dobby spec as an input"); + exit(EXIT_FAILURE); + } + else if (access(inputPath.c_str(), R_OK) != 0) + { + AI_LOG_ERROR("Cannot access Dobby spec file %s", inputPath.c_str()); + exit(EXIT_FAILURE); + } - // We'll create the directory if it's missing later, so no need to check - // if we can read it - if (outputDirectory.empty()) - { - AI_LOG_ERROR("Must provide an output directory"); - exit(EXIT_FAILURE); - } + // We'll create the directory if it's missing later, so no need to check + // if we can read it + if (outputDirectory.empty()) + { + AI_LOG_ERROR("Must provide an output directory"); + exit(EXIT_FAILURE); + } - // Dobby uses a JSON settings file to provide STB-specific settings (e.g GPU) - // Can be left blank (defaylt settings will be used) - else if (!settingsPath.empty() && access(settingsPath.c_str(), R_OK) != 0) - { - AI_LOG_ERROR("Cannot access settings file %s", inputPath.c_str()); - exit(EXIT_FAILURE); - } + // Dobby uses a JSON settings file to provide STB-specific settings (e.g GPU) + // Can be left blank (defaylt settings will be used) + else if (!settingsPath.empty() && access(settingsPath.c_str(), R_OK) != 0) + { + AI_LOG_ERROR("Cannot access settings file %s", inputPath.c_str()); + exit(EXIT_FAILURE); + } - AI_LOG_INFO("Parsing Dobby spec file %s\n", inputPath.c_str()); - AI_LOG_INFO("Generating Bundle in directory: %s\n", outputDirectory.c_str()); + AI_LOG_INFO("Parsing Dobby spec file %s\n", inputPath.c_str()); + AI_LOG_INFO("Generating Bundle in directory: %s\n", outputDirectory.c_str()); - // Get settings from the provided json file - auto settings = readSettings(); - auto utils = std::make_shared(); + // Get settings from the provided json file + auto settings = readSettings(); + auto utils = std::make_shared(); - // Now we can do some actual work - generateOciBundle(settings, utils, inputPath, outputDirectory); + // Now we can do some actual work + generateOciBundle(settings, utils, inputPath, outputDirectory); - // And we're done - AICommon::termLogging(); - return EXIT_SUCCESS; -} \ No newline at end of file + // And we're done + AICommon::termLogging(); + return EXIT_SUCCESS; + } catch (const std::exception& e) { + AI_LOG_ERROR_EXIT("Unhandled exception in main: %s\n", e.what()); + exit(EXIT_FAILURE); + } +} diff --git a/client/tool/source/Main.cpp b/client/tool/source/Main.cpp index a2afded68..79b8cd3b9 100644 --- a/client/tool/source/Main.cpp +++ b/client/tool/source/Main.cpp @@ -1554,7 +1554,6 @@ static void parseArgs(const int argc, char **argv) fprintf(stderr, "Warning: Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Warning: Unknown option character `\\x%x'.\n", optopt); - /* fall through */ default: exit(EXIT_FAILURE); break; diff --git a/daemon/lib/source/DobbyContainer.cpp b/daemon/lib/source/DobbyContainer.cpp index c210879e7..3eec0c90f 100644 --- a/daemon/lib/source/DobbyContainer.cpp +++ b/daemon/lib/source/DobbyContainer.cpp @@ -111,6 +111,7 @@ DobbyContainer::DobbyContainer(const std::shared_ptr& _bundle , hasCurseOfDeath(false) , state(State::Starting) , mRestartOnCrash(false) + , mRestartCount(0) { } @@ -127,6 +128,7 @@ DobbyContainer::DobbyContainer(const std::shared_ptr& _bundle , hasCurseOfDeath(false) , state(State::Starting) , mRestartOnCrash(false) + , mRestartCount(0) { } diff --git a/daemon/lib/source/DobbyLogRelay.cpp b/daemon/lib/source/DobbyLogRelay.cpp index aa0647811..24c7a2b12 100644 --- a/daemon/lib/source/DobbyLogRelay.cpp +++ b/daemon/lib/source/DobbyLogRelay.cpp @@ -41,6 +41,8 @@ DobbyLogRelay::DobbyLogRelay(const std::string &sourceSocketPath, const std::string &destinationSocketPath) : mSourceSocketPath(sourceSocketPath), mDestinationSocketPath(destinationSocketPath), + mDestinationSocketFd(-1), + mDestinationSocketAddress{}, mBuf{} { AI_LOG_FN_ENTRY(); diff --git a/daemon/lib/source/DobbyLogger.cpp b/daemon/lib/source/DobbyLogger.cpp index 6ea9e1540..4302763a7 100644 --- a/daemon/lib/source/DobbyLogger.cpp +++ b/daemon/lib/source/DobbyLogger.cpp @@ -90,30 +90,34 @@ DobbyLogger::DobbyLogger(const std::shared_ptr &settings) DobbyLogger::~DobbyLogger() { - AI_LOG_FN_ENTRY(); + try { + AI_LOG_FN_ENTRY(); - // Container loggers should remove themselves from the poll loop, but it doesn't really - // matter since if this class is being destructed the whole daemon is almost certainly - // shutting down - if (mJournaldRelay) - { - mJournaldRelay->removeFromPollLoop(mPollLoop); - } - if (mSyslogRelay) - { - mSyslogRelay->removeFromPollLoop(mPollLoop); - } - mPollLoop->stop(); + // Container loggers should remove themselves from the poll loop, but it doesn't really + // matter since if this class is being destructed the whole daemon is almost certainly + // shutting down + if (mJournaldRelay) + { + mJournaldRelay->removeFromPollLoop(mPollLoop); + } + if (mSyslogRelay) + { + mSyslogRelay->removeFromPollLoop(mPollLoop); + } + mPollLoop->stop(); - // Close all our open sockets - if (shutdown(mSocketFd, SHUT_RDWR) < 0) - { - AI_LOG_SYS_WARN(errno, "Failed to shutdown socket %s", mSocketPath.c_str()); - } + // Close all our open sockets + if (shutdown(mSocketFd, SHUT_RDWR) < 0) + { + AI_LOG_SYS_WARN(errno, "Failed to shutdown socket %s", mSocketPath.c_str()); + } - closeAndDeleteSocket(mSocketFd, mSocketPath); + closeAndDeleteSocket(mSocketFd, mSocketPath); - AI_LOG_FN_EXIT(); + AI_LOG_FN_EXIT(); + } catch (const std::exception& e) { + AI_LOG_SYS_ERROR(errno, "Caught Exception in ~DobbyLogger: %s", e.what()); + } } /** diff --git a/daemon/lib/source/DobbyManager.cpp b/daemon/lib/source/DobbyManager.cpp index 2e47c9b51..71b070f35 100644 --- a/daemon/lib/source/DobbyManager.cpp +++ b/daemon/lib/source/DobbyManager.cpp @@ -482,6 +482,7 @@ void DobbyManager::cleanupContainersShutdown() { AI_LOG_FN_ENTRY(); + std::lock_guard locker(mLock); AI_LOG_INFO("Dobby shutting down - stopping %lu containers", mContainers.size()); auto it = mContainers.begin(); @@ -1633,7 +1634,7 @@ bool DobbyManager::hibernateContainer(int32_t cd, const std::string& options) } std::thread hibernateThread = - std::thread([=]() + std::thread([id, cd, dest = std::move(dest), compress, this]() { DobbyHibernate::Error ret = DobbyHibernate::Error::ErrorNone; // create a stats object for the container to get list of PIDs @@ -3405,7 +3406,6 @@ bool DobbyManager::invalidContainerCleanupTask() // Pid is still valid. Attempt to send SIGKILL mRunc->killCont(it->first, SIGKILL, true); - // Note: This sleep is in a cleanup task that runs periodically, holding lock briefly is acceptable // Did we actually kill it? Give it some time, then check the status std::this_thread::sleep_for(std::chrono::milliseconds(200)); DobbyRunC::ContainerStatus state = mRunc->state(it->first); diff --git a/daemon/lib/source/DobbyWorkQueue.cpp b/daemon/lib/source/DobbyWorkQueue.cpp index d897cd45a..0c935ccbc 100644 --- a/daemon/lib/source/DobbyWorkQueue.cpp +++ b/daemon/lib/source/DobbyWorkQueue.cpp @@ -250,6 +250,7 @@ bool DobbyWorkQueue::postWork(WorkFunc &&work) if (std::this_thread::get_id() == mRunningThreadId) { // add to the queue + std::unique_lock locker(mWorkQueueLock); const uint64_t tag = ++mWorkCounter; mWorkQueue.emplace(tag, std::move(work)); } diff --git a/daemon/process/source/Main.cpp b/daemon/process/source/Main.cpp index 0daee98b3..26f6aeb3c 100644 --- a/daemon/process/source/Main.cpp +++ b/daemon/process/source/Main.cpp @@ -230,7 +230,6 @@ static void parseArgs(int argc, char **argv) fprintf(stderr, "Warning: Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Warning: Unknown option character `\\x%x'.\n", optopt); - /* fall through */ default: exit(EXIT_FAILURE); break; @@ -496,129 +495,137 @@ static std::shared_ptr setupIpcService() */ int main(int argc, char * argv[]) { - int rc = EXIT_SUCCESS; + try { + int rc = EXIT_SUCCESS; - parseArgs(argc, argv); + parseArgs(argc, argv); - // Set our priority if requested - if (gPriority > 0) - { - struct sched_param param; - param.sched_priority = gPriority; - sched_setscheduler(0, SCHED_RR, ¶m); - } + // Set our priority if requested + if (gPriority > 0) + { + struct sched_param param; + param.sched_priority = gPriority; + sched_setscheduler(0, SCHED_RR, ¶m); + } - // Setup the AI logging stuff - unsigned logTargets = Dobby::Console; - if (gUseSyslog) - { - logTargets |= Dobby::SysLog; - } + // Setup the AI logging stuff + unsigned logTargets = Dobby::Console; + if (gUseSyslog) + { + logTargets |= Dobby::SysLog; + } - // Also log to journald on the RDK builds - if (gUseJournald) - { - logTargets |= Dobby::Journald; - } + // Also log to journald on the RDK builds + if (gUseJournald) + { + logTargets |= Dobby::Journald; + } - Dobby::setupLogging(logTargets); - __ai_debug_log_level = gLogLevel; + Dobby::setupLogging(logTargets); + __ai_debug_log_level = gLogLevel; - AI_LOG_MILESTONE("starting Dobby daemon"); + AI_LOG_MILESTONE("starting Dobby daemon"); - // Daemonise ourselves to run in the background - if (gDaemonise) - { - daemonise(); + // Daemonise ourselves to run in the background + if (gDaemonise) + { + daemonise(); - logTargets &= ~Dobby::Console; - Dobby::setupLogging(logTargets); - } - // Shutdown the console if asked to - else if (gNoConsole) - { - closeConsole(); + logTargets &= ~Dobby::Console; + Dobby::setupLogging(logTargets); + } + // Shutdown the console if asked to + else if (gNoConsole) + { + closeConsole(); - logTargets &= ~Dobby::Console; - Dobby::setupLogging(logTargets); - } + logTargets &= ~Dobby::Console; + Dobby::setupLogging(logTargets); + } - // Create object storing Dobby settings - const std::shared_ptr settings = createSettings(); + // Create object storing Dobby settings + const std::shared_ptr settings = createSettings(); - // Setup signals, this MUST be done in the main thread before any other - // threads are spawned - Dobby::configSignals(); + // Setup signals, this MUST be done in the main thread before any other + // threads are spawned + Dobby::configSignals(); - // Initialise tracing on debug builds (warning: this must be done after the - // Dobby::configSignals() call above, because it spawns threads that mess - // with the signal masks) + // Initialise tracing on debug builds (warning: this must be done after the + // Dobby::configSignals() call above, because it spawns threads that mess + // with the signal masks) #if defined(AI_ENABLE_TRACING) - PerfettoTracing::initialise(); + PerfettoTracing::initialise(); #endif - AI_LOG_INFO("starting dbus service"); + AI_LOG_INFO("starting dbus service"); #if defined(USE_SYSTEMD) - AI_LOG_INFO("Dobby built with systemd support - using sd-bus"); + AI_LOG_INFO("Dobby built with systemd support - using sd-bus"); #else - AI_LOG_INFO("Dobby built without systemd support - using libdbus"); + AI_LOG_INFO("Dobby built without systemd support - using libdbus"); #endif - AI_LOG_INFO(" dbus address '%s'", gDbusAddress.c_str()); - AI_LOG_INFO(" service name '%s'", DOBBY_SERVICE); - AI_LOG_INFO(" object name '%s'", DOBBY_OBJECT); + AI_LOG_INFO(" dbus address '%s'", gDbusAddress.c_str()); + AI_LOG_INFO(" service name '%s'", DOBBY_SERVICE); + AI_LOG_INFO(" object name '%s'", DOBBY_OBJECT); - // Create the IPC service and start it, this spawns a thread and runs the dbus - // event loop inside it. - std::shared_ptr ipcService = setupIpcService(); + // Create the IPC service and start it, this spawns a thread and runs the dbus + // event loop inside it. + std::shared_ptr ipcService = setupIpcService(); - if (!ipcService) - { - rc = EXIT_FAILURE; - } - else if (!ipcService->isServiceAvailable(DOBBY_SERVICE)) - { - // Double check we did actually make ourselves available on the bus - AI_LOG_ERROR("IPC Service initialised but service %s is not available on the bus", DOBBY_SERVICE); - rc = EXIT_FAILURE; - } - else - { - // Create the dobby object and hook into the IPC service - Dobby dobby(ipcService->getBusAddress(), ipcService, settings); + if (!ipcService) + { + rc = EXIT_FAILURE; + } + else if (!ipcService->isServiceAvailable(DOBBY_SERVICE)) + { + // Double check we did actually make ourselves available on the bus + AI_LOG_ERROR("IPC Service initialised but service %s is not available on the bus", DOBBY_SERVICE); + rc = EXIT_FAILURE; + } + else + { + // Create the dobby object and hook into the IPC service + Dobby dobby(ipcService->getBusAddress(), ipcService, settings); - // On debug builds try and detect the AI dbus addresses at startup + // On debug builds try and detect the AI dbus addresses at startup #if (AI_BUILD_TYPE == AI_DEBUG) - dobby.setDefaultAIDbusAddresses(getAIDbusAddress(true), + dobby.setDefaultAIDbusAddresses(getAIDbusAddress(true), getAIDbusAddress(false)); #endif // (AI_BUILD_TYPE == AI_DEBUG) - // Start the service, this spawns a thread and runs the dbus event - // loop inside it - ipcService->start(); + // Start the service, this spawns a thread and runs the dbus event + // loop inside it + ipcService->start(); - // Milestone - AI_LOG_MILESTONE("started Dobby daemon"); + // Milestone + AI_LOG_MILESTONE("started Dobby daemon"); - // Wait till the Dobby service is terminated, this is obviously a - // blocking call - dobby.run(); + // Wait till the Dobby service is terminated, this is obviously a + // blocking call + dobby.run(); - // Stop the service and fall out - ipcService->stop(); - } + // Stop the service and fall out + ipcService->stop(); + } - // Milestone - if (rc == EXIT_SUCCESS) - { - AI_LOG_MILESTONE("stopped Dobby daemon"); - } + // Milestone + if (rc == EXIT_SUCCESS) + { + AI_LOG_MILESTONE("stopped Dobby daemon"); + } - // And we're done - AICommon::termLogging(); - return rc; + // And we're done + AICommon::termLogging(); + return rc; + } catch (const std::exception& e) { + AI_LOG_FATAL("Unhandled exception in main: %s", e.what()); + return EXIT_FAILURE; + } catch (...) { + AI_LOG_FATAL("Unhandled unknown exception in main"); + return EXIT_FAILURE; + } } diff --git a/pluginLauncher/lib/source/DobbyRdkPluginManager.cpp b/pluginLauncher/lib/source/DobbyRdkPluginManager.cpp index ec33fa6e7..c9bbd727c 100644 --- a/pluginLauncher/lib/source/DobbyRdkPluginManager.cpp +++ b/pluginLauncher/lib/source/DobbyRdkPluginManager.cpp @@ -344,7 +344,6 @@ bool DobbyRdkPluginManager::loadPlugins() free(namelist); closedir(dir); - // dirFd is now invalid - closedir() closed it AI_LOG_FN_EXIT(); return true; diff --git a/pluginLauncher/lib/source/DobbyRdkPluginUtils.cpp b/pluginLauncher/lib/source/DobbyRdkPluginUtils.cpp index 9d4b2f935..9c03d6a74 100644 --- a/pluginLauncher/lib/source/DobbyRdkPluginUtils.cpp +++ b/pluginLauncher/lib/source/DobbyRdkPluginUtils.cpp @@ -39,7 +39,8 @@ DobbyRdkPluginUtils::DobbyRdkPluginUtils(const std::shared_ptr &cfg, const std::string& containerId) - : mConf(cfg) + : exitStatus(-1) + , mConf(cfg) , mContainerId(containerId) { AI_LOG_FN_ENTRY(); @@ -50,7 +51,8 @@ DobbyRdkPluginUtils::DobbyRdkPluginUtils(const std::shared_ptr DobbyRdkPluginUtils::DobbyRdkPluginUtils(const std::shared_ptr &cfg, const std::shared_ptr &startState, const std::string& containerId) - : mConf(cfg) + : exitStatus(-1) + , mConf(cfg) , mStartState(startState) , mContainerId(containerId) { @@ -62,7 +64,8 @@ DobbyRdkPluginUtils::DobbyRdkPluginUtils(const std::shared_ptr DobbyRdkPluginUtils::DobbyRdkPluginUtils(const std::shared_ptr &cfg, const std::shared_ptr &state, const std::string& containerId) - : mConf(cfg) + : exitStatus(-1) + , mConf(cfg) , mState(state) , mContainerId(containerId) { @@ -75,7 +78,8 @@ DobbyRdkPluginUtils::DobbyRdkPluginUtils(const std::shared_ptr const std::shared_ptr &state, const std::shared_ptr &startState, const std::string& containerId) - : mConf(cfg) + : exitStatus(-1) + , mConf(cfg) , mState(state) , mStartState(startState) , mContainerId(containerId) diff --git a/pluginLauncher/tool/source/Main.cpp b/pluginLauncher/tool/source/Main.cpp index 915b04fec..4e0530245 100644 --- a/pluginLauncher/tool/source/Main.cpp +++ b/pluginLauncher/tool/source/Main.cpp @@ -119,7 +119,6 @@ static void parseArgs(const int argc, char **argv) fprintf(stderr, "Warning: Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Warning: Unknown option character `\\x%x'.\n", optopt); - /* fall through */ default: exit(EXIT_FAILURE); break; diff --git a/plugins/EthanLog/client/cat/ethanlog-cat.cpp b/plugins/EthanLog/client/cat/ethanlog-cat.cpp index e9284af4e..cea643b2a 100644 --- a/plugins/EthanLog/client/cat/ethanlog-cat.cpp +++ b/plugins/EthanLog/client/cat/ethanlog-cat.cpp @@ -114,7 +114,7 @@ class PipeInput { // read as much to fill in the buffer ssize_t rc = TEMP_FAILURE_RETRY(read(mFd, mBuffer + mBufferOffset, sizeof(mBuffer) - mBufferOffset)); - if (rc <= 0) + if ((rc <= 0) || ((size_t)rc > sizeof(mBuffer) - mBufferOffset)) { mValid = false; return; @@ -361,7 +361,6 @@ static void parseArgs(int argc, char **argv) fprintf(stderr, "Warning: Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Warning: Unknown option character `\\x%x'.\n", optopt); - /* fall through */ default: exit(EXIT_FAILURE); } diff --git a/plugins/EthanLog/source/EthanLogClient.cpp b/plugins/EthanLog/source/EthanLogClient.cpp index 7798f8d32..e52535bc5 100644 --- a/plugins/EthanLog/source/EthanLogClient.cpp +++ b/plugins/EthanLog/source/EthanLogClient.cpp @@ -567,7 +567,8 @@ void EthanLogClient::processLogData() if (ret < 0) break; - numFields += ret; + if (ret > 0 && numFields + ret <= maxFields && numFields + ret > 0) + numFields += ret; } thisField = nextField; diff --git a/plugins/MulticastSockets/source/MulticastSocketsPlugin.cpp b/plugins/MulticastSockets/source/MulticastSocketsPlugin.cpp index 1afbca39f..307b0bb6b 100644 --- a/plugins/MulticastSockets/source/MulticastSocketsPlugin.cpp +++ b/plugins/MulticastSockets/source/MulticastSocketsPlugin.cpp @@ -106,6 +106,12 @@ bool MulticastSocketPlugin::postConstruction(const ContainerId &id, for (const MulticastSocket &serverSocket : serverSockets) { int socket = createServerSocket(serverSocket.ipAddress, serverSocket.portNumber); + if (socket < 0) + { + AI_LOG_ERROR("Failed to create server socket for container %s", id.c_str()); + return false; + } + int duppedSocket = startupState->addFileDescriptor(mName, socket); close(socket); //close original fd, it's already dupped and stored in startupState @@ -116,7 +122,7 @@ bool MulticastSocketPlugin::postConstruction(const ContainerId &id, } char envVar[256]; - snprintf(envVar, sizeof(envVar), "MCAST_SERVER_SOCKET_%s_FD=%u", serverSocket.name.c_str(), duppedSocket); + snprintf(envVar, sizeof(envVar), "MCAST_SERVER_SOCKET_%s_FD=%d", serverSocket.name.c_str(), duppedSocket); if (!startupState->addEnvironmentVariable(envVar)) { AI_LOG_ERROR("Failed to set env variable for container %s", id.c_str()); @@ -127,6 +133,12 @@ bool MulticastSocketPlugin::postConstruction(const ContainerId &id, for (const std::string &clientSocket : clientSockets) { int socket = createClientSocket(); + if (socket < 0) + { + AI_LOG_ERROR("Failed to create client socket for container %s", id.c_str()); + return false; + } + int duppedSocket = startupState->addFileDescriptor(mName, socket); close(socket); //close original fd, it's already dupped and stored in startupState @@ -137,7 +149,7 @@ bool MulticastSocketPlugin::postConstruction(const ContainerId &id, } char envVar[256]; - snprintf(envVar, sizeof(envVar), "MCAST_CLIENT_SOCKET_%s_FD=%u", clientSocket.c_str(), duppedSocket); + snprintf(envVar, sizeof(envVar), "MCAST_CLIENT_SOCKET_%s_FD=%d", clientSocket.c_str(), duppedSocket); if (!startupState->addEnvironmentVariable(envVar)) { AI_LOG_ERROR("Failed to set env variable for container %s", id.c_str()); diff --git a/rdkPlugins/AppServices/source/AppServicesRdkPlugin.cpp b/rdkPlugins/AppServices/source/AppServicesRdkPlugin.cpp index 9456ba776..dc527593f 100644 --- a/rdkPlugins/AppServices/source/AppServicesRdkPlugin.cpp +++ b/rdkPlugins/AppServices/source/AppServicesRdkPlugin.cpp @@ -32,6 +32,7 @@ AppServicesRdkPlugin::AppServicesRdkPlugin(std::shared_ptr &con mContainerConfig(containerConfig), mUtils(utils), mRootfsPath(rootfsPath), + mPluginConfig(nullptr), mNetfilter(std::make_shared()), mEnableConnLimit(false) { @@ -687,4 +688,4 @@ std::string AppServicesRdkPlugin::createMasqueradeSnatRule(const std::string &ip ipAddress.c_str()); return std::string(buf); -} \ No newline at end of file +} diff --git a/rdkPlugins/HttpProxy/source/HttpProxyPlugin.cpp b/rdkPlugins/HttpProxy/source/HttpProxyPlugin.cpp index 4151b5b68..2fa5a5de9 100644 --- a/rdkPlugins/HttpProxy/source/HttpProxyPlugin.cpp +++ b/rdkPlugins/HttpProxy/source/HttpProxyPlugin.cpp @@ -34,6 +34,7 @@ HttpProxyPlugin::HttpProxyPlugin(std::shared_ptr &cfg, const std::string &rootfsPath) : mName("HttpProxy"), mContainerConfig(cfg), + mPluginData(nullptr), mUtils(utils), mMountedCACertsPath(rootfsPath + "../ca-certificates.crt") { @@ -350,4 +351,4 @@ bool HttpProxyPlugin::cleanup() AI_LOG_FN_EXIT(); return true; -} \ No newline at end of file +} diff --git a/rdkPlugins/IONMemory/source/IonMemoryPlugin.cpp b/rdkPlugins/IONMemory/source/IonMemoryPlugin.cpp index 77d285fc1..225d808d7 100644 --- a/rdkPlugins/IONMemory/source/IonMemoryPlugin.cpp +++ b/rdkPlugins/IONMemory/source/IonMemoryPlugin.cpp @@ -39,7 +39,8 @@ IonMemoryPlugin::IonMemoryPlugin(std::shared_ptr &containerConf : mName("IonMemory"), mContainerConfig(containerConfig), mUtils(utils), - mRootfsPath(rootfsPath) + mRootfsPath(rootfsPath), + mPluginData(nullptr) { AI_LOG_FN_ENTRY(); diff --git a/rdkPlugins/Logging/source/FileSink.cpp b/rdkPlugins/Logging/source/FileSink.cpp index 4beb5fe6b..f9912e83c 100644 --- a/rdkPlugins/Logging/source/FileSink.cpp +++ b/rdkPlugins/Logging/source/FileSink.cpp @@ -41,6 +41,7 @@ FileSink::FileSink(const std::string &containerId, std::shared_ptr &containerConfig) : mContainerConfig(containerConfig), mContainerId(containerId), + mFileSizeLimit(-1), mLimitHit(false), mBuf{} { @@ -264,4 +265,4 @@ int FileSink::openFile(const std::string &pathName) } return openedFd; -} \ No newline at end of file +} diff --git a/rdkPlugins/Networking/source/NetworkingPlugin.cpp b/rdkPlugins/Networking/source/NetworkingPlugin.cpp index 650e3aeb8..0035845d0 100644 --- a/rdkPlugins/Networking/source/NetworkingPlugin.cpp +++ b/rdkPlugins/Networking/source/NetworkingPlugin.cpp @@ -42,6 +42,7 @@ NetworkingPlugin::NetworkingPlugin(std::shared_ptr &cfg, mContainerConfig(cfg), mUtils(utils), mRootfsPath(rootfsPath), + mPluginData(nullptr), mNetfilter(std::make_shared()) { AI_LOG_FN_ENTRY(); diff --git a/rdkPlugins/Storage/source/DynamicMountDetails.cpp b/rdkPlugins/Storage/source/DynamicMountDetails.cpp index 8c7f6f529..7ba9f3943 100644 --- a/rdkPlugins/Storage/source/DynamicMountDetails.cpp +++ b/rdkPlugins/Storage/source/DynamicMountDetails.cpp @@ -153,11 +153,7 @@ bool DynamicMountDetails::onCreateContainer() const // Recursively create destination directory structure if (mUtils->mkdirRecursive(dirPath, 0755) || (errno == EEXIST)) { - if (isDir) - { - success = true; - } - else + if (!isDir) { // If mounting a file, make sure a file with the same name // exists at the desination path prior to bind mounting. @@ -166,12 +162,9 @@ bool DynamicMountDetails::onCreateContainer() const // Creating the file first ensures an inode exists for the // bind mount to target. int fd = open(targetPath.c_str(), O_RDONLY | O_CREAT, 0644); - if ((fd >= 0) || (errno == EEXIST)) + if (fd >= 0) { - if (fd >= 0) - { - close(fd); - } + close(fd); success = true; } else diff --git a/settings/source/Settings.cpp b/settings/source/Settings.cpp index 96081033b..8e84d04ab 100644 --- a/settings/source/Settings.cpp +++ b/settings/source/Settings.cpp @@ -820,6 +820,7 @@ std::list Settings::getPathsFromJson(const Json::Value& value) cons { AI_LOG_ERROR("failed to expand settings path string '%s'", value.asCString()); + wordfree(&exp); return std::list(); } From 8ba7846ddc7615438044adb27c8acaf8f87c278a Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Wed, 21 Jan 2026 15:48:38 +0530 Subject: [PATCH 03/28] Update DobbyManager.cpp --- daemon/lib/source/DobbyManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/lib/source/DobbyManager.cpp b/daemon/lib/source/DobbyManager.cpp index 71b070f35..18efc4170 100644 --- a/daemon/lib/source/DobbyManager.cpp +++ b/daemon/lib/source/DobbyManager.cpp @@ -1639,8 +1639,8 @@ bool DobbyManager::hibernateContainer(int32_t cd, const std::string& options) DobbyHibernate::Error ret = DobbyHibernate::Error::ErrorNone; // create a stats object for the container to get list of PIDs std::unique_lock locker(mLock); - DobbyStats stats(it->first, mEnvironment, mUtilities); - Json::Value jsonPids = DobbyStats(it->first, mEnvironment, mUtilities).stats()["pids"]; + DobbyStats stats(id, mEnvironment, mUtilities); + Json::Value jsonPids = DobbyStats(id, mEnvironment, mUtilities).stats()["pids"]; locker.unlock(); for (auto pidIt = jsonPids.begin(); pidIt != jsonPids.end(); ++pidIt) From 938881959ba2eafa57c44eb287ffaedf24ec94ab Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Thu, 22 Jan 2026 06:50:01 +0530 Subject: [PATCH 04/28] Update DobbyManager.cpp --- daemon/lib/source/DobbyManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/lib/source/DobbyManager.cpp b/daemon/lib/source/DobbyManager.cpp index 18efc4170..6f2fb0be6 100644 --- a/daemon/lib/source/DobbyManager.cpp +++ b/daemon/lib/source/DobbyManager.cpp @@ -482,7 +482,7 @@ void DobbyManager::cleanupContainersShutdown() { AI_LOG_FN_ENTRY(); - std::lock_guard locker(mLock); + // std::lock_guard locker(mLock); AI_LOG_INFO("Dobby shutting down - stopping %lu containers", mContainers.size()); auto it = mContainers.begin(); From f75dfe667e087a4f0771b30cf2bbce2da40d49f3 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Thu, 22 Jan 2026 07:00:21 +0530 Subject: [PATCH 05/28] Update DobbyManager.cpp --- daemon/lib/source/DobbyManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/lib/source/DobbyManager.cpp b/daemon/lib/source/DobbyManager.cpp index 6f2fb0be6..18efc4170 100644 --- a/daemon/lib/source/DobbyManager.cpp +++ b/daemon/lib/source/DobbyManager.cpp @@ -482,7 +482,7 @@ void DobbyManager::cleanupContainersShutdown() { AI_LOG_FN_ENTRY(); - // std::lock_guard locker(mLock); + std::lock_guard locker(mLock); AI_LOG_INFO("Dobby shutting down - stopping %lu containers", mContainers.size()); auto it = mContainers.begin(); From 9756bc7161a9a14566f8229b4172c2e425d22237 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Thu, 22 Jan 2026 07:26:54 +0530 Subject: [PATCH 06/28] Update DobbyManager.cpp --- daemon/lib/source/DobbyManager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/daemon/lib/source/DobbyManager.cpp b/daemon/lib/source/DobbyManager.cpp index 18efc4170..38122bf6d 100644 --- a/daemon/lib/source/DobbyManager.cpp +++ b/daemon/lib/source/DobbyManager.cpp @@ -482,7 +482,7 @@ void DobbyManager::cleanupContainersShutdown() { AI_LOG_FN_ENTRY(); - std::lock_guard locker(mLock); + std::unique_lock locker(mLock); AI_LOG_INFO("Dobby shutting down - stopping %lu containers", mContainers.size()); auto it = mContainers.begin(); @@ -495,9 +495,13 @@ void DobbyManager::cleanupContainersShutdown() (it->second->state == DobbyContainer::State::Awakening)) { AI_LOG_INFO("Stopping container %s", it->first.c_str()); + int32_t descriptor = it->second->descriptor; + locker.unlock(); // By calling the "proper" stop method here, any listening services will be // notified of the container stop event - if (!stopContainer(it->second->descriptor, false)) + bool stopSuccess = stopContainer(descriptor, false); + locker.lock(); + if (!stopSuccess) { // As DobbyRunC::killCont already handles problem of masked SIGTERM in // case we failed to stop it means that it tried to SIGKILL too, so From 1a532ab96a6f8b434588766f13a010b85b334313 Mon Sep 17 00:00:00 2001 From: dkumar798_comcast Date: Thu, 22 Jan 2026 09:29:19 +0000 Subject: [PATCH 07/28] RDKEMW-12282: Fix Coverity identified issues - dobby --- .../Common/source/ThreadedDispatcher.cpp | 16 +++++++++----- bundle/lib/source/DobbyBundleConfig.cpp | 1 + bundle/lib/source/DobbySpecConfig.cpp | 1 + bundle/tool/source/Main.cpp | 1 + client/tool/source/Main.cpp | 2 ++ daemon/lib/source/DobbyManager.cpp | 22 ++++++++++++++----- daemon/process/source/Main.cpp | 2 ++ pluginLauncher/tool/source/Main.cpp | 1 + plugins/EthanLog/client/cat/ethanlog-cat.cpp | 1 + .../Storage/source/DynamicMountDetails.cpp | 1 - 10 files changed, 36 insertions(+), 12 deletions(-) diff --git a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp index 7666d4313..56637caad 100644 --- a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp +++ b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp @@ -135,19 +135,25 @@ void ThreadedDispatcher::flush() std::unique_lock runningLocker(m); if(running) { - runningLocker.unlock(); std::mutex flushMutex; std::condition_variable flushCond; bool flushed = false; std::unique_lock locker(flushMutex); post([&]() { - std::lock_guard lock(flushMutex); - flushed = true; - running = false; + { + std::lock_guard lock(flushMutex); + flushed = true; + } + + { + std::lock_guard runningLock(m); + running = false; + } flushCond.notify_one(); }); + runningLocker.unlock(); while (!flushed) { flushCond.wait(locker); } @@ -156,7 +162,6 @@ void ThreadedDispatcher::flush() } else { - runningLocker.unlock(); AI_LOG_WARN("This dispatcher is no longer running. Ignoring flush request."); } } @@ -179,6 +184,7 @@ ThreadedDispatcher::~ThreadedDispatcher() } bool ThreadedDispatcher::hasMoreWorkOrWasStopRequested() { + std::unique_lock lock(m); return !q.empty() || !running; } void ThreadedDispatcher::doWork(const std::string& name, int priority) diff --git a/bundle/lib/source/DobbyBundleConfig.cpp b/bundle/lib/source/DobbyBundleConfig.cpp index 26c65b7d6..a5bc8d7e9 100644 --- a/bundle/lib/source/DobbyBundleConfig.cpp +++ b/bundle/lib/source/DobbyBundleConfig.cpp @@ -241,6 +241,7 @@ void DobbyBundleConfig::setUidGidMappings(uid_t userId, gid_t groupId) const std::string& DobbyBundleConfig::rootfsPath() const { + std::lock_guard locker(mLock); return mRootfsPath; } diff --git a/bundle/lib/source/DobbySpecConfig.cpp b/bundle/lib/source/DobbySpecConfig.cpp index 1cb6627db..5d85f526b 100644 --- a/bundle/lib/source/DobbySpecConfig.cpp +++ b/bundle/lib/source/DobbySpecConfig.cpp @@ -920,6 +920,7 @@ bool DobbySpecConfig::processRtPriority(const Json::Value& value, int rtPriorityDefault = 0; int rtPriorityLimit = 0; + std::lock_guard locker(mLock); if (mSpecVersion == SpecVersion::Version1_0) { if (!value.isIntegral()) diff --git a/bundle/tool/source/Main.cpp b/bundle/tool/source/Main.cpp index c9f3a1848..ac789742e 100644 --- a/bundle/tool/source/Main.cpp +++ b/bundle/tool/source/Main.cpp @@ -113,6 +113,7 @@ static void parseArgs(const int argc, char **argv) fprintf(stderr, "Warning: Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Warning: Unknown option character `\\x%x'.\n", optopt); + break; default: exit(EXIT_FAILURE); break; diff --git a/client/tool/source/Main.cpp b/client/tool/source/Main.cpp index 79b8cd3b9..458d89d42 100644 --- a/client/tool/source/Main.cpp +++ b/client/tool/source/Main.cpp @@ -1554,6 +1554,8 @@ static void parseArgs(const int argc, char **argv) fprintf(stderr, "Warning: Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Warning: Unknown option character `\\x%x'.\n", optopt); + break; + default: exit(EXIT_FAILURE); break; diff --git a/daemon/lib/source/DobbyManager.cpp b/daemon/lib/source/DobbyManager.cpp index 38122bf6d..337d9e868 100644 --- a/daemon/lib/source/DobbyManager.cpp +++ b/daemon/lib/source/DobbyManager.cpp @@ -494,13 +494,20 @@ void DobbyManager::cleanupContainersShutdown() (it->second->state == DobbyContainer::State::Hibernated) || \ (it->second->state == DobbyContainer::State::Awakening)) { - AI_LOG_INFO("Stopping container %s", it->first.c_str()); + ContainerId id = it->first; int32_t descriptor = it->second->descriptor; + AI_LOG_INFO("Stopping container %s", id.c_str()); + ++it; locker.unlock(); // By calling the "proper" stop method here, any listening services will be // notified of the container stop event bool stopSuccess = stopContainer(descriptor, false); locker.lock(); + + auto eraseIt = mContainers.find(id); + if (eraseIt == mContainers.end()) + continue; + if (!stopSuccess) { // As DobbyRunC::killCont already handles problem of masked SIGTERM in @@ -508,18 +515,21 @@ void DobbyManager::cleanupContainersShutdown() // container must be in uninterrable sleep and we cannot do anything // Remove it container from the list (even though it wasn't clean up) // to avoid repeating indefinitely. It will be cleaned on boot-up - std::string containerId = it->first.c_str(); - it = mContainers.erase(it); - AI_LOG_ERROR("Failed to stop container %s. Will attempt to clean up at daemon restart", containerId.c_str()); + mContainers.erase(eraseIt); + AI_LOG_ERROR("Failed to stop container %s. Will attempt to clean up at daemon restart", id.c_str()); } else { // This would normally be done async by the runc monitor thread, but we're // shutting down so we want to run synchronously - handleContainerTerminate(it->first, it->second, 0); - it = mContainers.erase(it); + handleContainerTerminate(eraseIt->first, eraseIt->second, 0); + mContainers.erase(eraseIt); } } + else + { + ++it; + } } AI_LOG_FN_EXIT(); diff --git a/daemon/process/source/Main.cpp b/daemon/process/source/Main.cpp index 26f6aeb3c..3b612197f 100644 --- a/daemon/process/source/Main.cpp +++ b/daemon/process/source/Main.cpp @@ -230,6 +230,8 @@ static void parseArgs(int argc, char **argv) fprintf(stderr, "Warning: Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Warning: Unknown option character `\\x%x'.\n", optopt); + break; + default: exit(EXIT_FAILURE); break; diff --git a/pluginLauncher/tool/source/Main.cpp b/pluginLauncher/tool/source/Main.cpp index 4e0530245..d4d9d26d2 100644 --- a/pluginLauncher/tool/source/Main.cpp +++ b/pluginLauncher/tool/source/Main.cpp @@ -119,6 +119,7 @@ static void parseArgs(const int argc, char **argv) fprintf(stderr, "Warning: Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Warning: Unknown option character `\\x%x'.\n", optopt); + break; default: exit(EXIT_FAILURE); break; diff --git a/plugins/EthanLog/client/cat/ethanlog-cat.cpp b/plugins/EthanLog/client/cat/ethanlog-cat.cpp index cea643b2a..365225d17 100644 --- a/plugins/EthanLog/client/cat/ethanlog-cat.cpp +++ b/plugins/EthanLog/client/cat/ethanlog-cat.cpp @@ -361,6 +361,7 @@ static void parseArgs(int argc, char **argv) fprintf(stderr, "Warning: Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Warning: Unknown option character `\\x%x'.\n", optopt); + break; default: exit(EXIT_FAILURE); } diff --git a/rdkPlugins/Storage/source/DynamicMountDetails.cpp b/rdkPlugins/Storage/source/DynamicMountDetails.cpp index 7ba9f3943..2a93f2a87 100644 --- a/rdkPlugins/Storage/source/DynamicMountDetails.cpp +++ b/rdkPlugins/Storage/source/DynamicMountDetails.cpp @@ -165,7 +165,6 @@ bool DynamicMountDetails::onCreateContainer() const if (fd >= 0) { close(fd); - success = true; } else { From 161d7b0ec8e6f1079e1c93999f0efff3af6d4eae Mon Sep 17 00:00:00 2001 From: dkumar798_comcast Date: Thu, 22 Jan 2026 10:04:36 +0000 Subject: [PATCH 08/28] RDKEMW-12282: Fix Coverity identified issues - dobby --- plugins/EthanLog/source/EthanLogClient.cpp | 5 +++++ rdkPlugins/Storage/source/RefCountFile.cpp | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/plugins/EthanLog/source/EthanLogClient.cpp b/plugins/EthanLog/source/EthanLogClient.cpp index e52535bc5..57549939d 100644 --- a/plugins/EthanLog/source/EthanLogClient.cpp +++ b/plugins/EthanLog/source/EthanLogClient.cpp @@ -495,6 +495,11 @@ void EthanLogClient::processLogData() // skip empty fields if (fieldLen > 0) { + if (numFields < 0 || numFields >= maxFields) + { + ret = -1; + break; + } switch (*thisField++) { case 'L': diff --git a/rdkPlugins/Storage/source/RefCountFile.cpp b/rdkPlugins/Storage/source/RefCountFile.cpp index 5decaeec2..bf529938a 100644 --- a/rdkPlugins/Storage/source/RefCountFile.cpp +++ b/rdkPlugins/Storage/source/RefCountFile.cpp @@ -111,18 +111,26 @@ int RefCountFile::Increment() if (ref >= 0) { - if (ref == INT_MAX) + if (ref >= INT_MAX) { AI_LOG_ERROR("Reference count overflow at INT_MAX"); AI_LOG_FN_EXIT(); return -1; } - ref = Write(++ref); - AI_LOG_DEBUG("ref count: %d", ref); + int newRef = ref + 1; + int writtenRef = Write(newRef); + + if (writtenRef < 0 || writtenRef > INT_MAX) + { + AI_LOG_ERROR("Invalid ref count returned from Write(): %d", writtenRef); + AI_LOG_FN_EXIT(); + return -1; + } + AI_LOG_DEBUG("ref count: %d", writtenRef); } AI_LOG_FN_EXIT(); - return ref; + return writtenRef; } // ----------------------------------------------------------------------------- @@ -217,4 +225,4 @@ int RefCountFile::Write(int ref) AI_LOG_FN_EXIT(); return ret; -} \ No newline at end of file +} From 7832785b50da01999ce71c0797abcb69f17b2649 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Thu, 22 Jan 2026 15:43:59 +0530 Subject: [PATCH 09/28] Update RefCountFile.cpp --- rdkPlugins/Storage/source/RefCountFile.cpp | 35 +++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/rdkPlugins/Storage/source/RefCountFile.cpp b/rdkPlugins/Storage/source/RefCountFile.cpp index bf529938a..ab7fb2ea1 100644 --- a/rdkPlugins/Storage/source/RefCountFile.cpp +++ b/rdkPlugins/Storage/source/RefCountFile.cpp @@ -109,26 +109,27 @@ int RefCountFile::Increment() int ref = Read(); - if (ref >= 0) - { - if (ref >= INT_MAX) - { - AI_LOG_ERROR("Reference count overflow at INT_MAX"); - AI_LOG_FN_EXIT(); - return -1; - } - int newRef = ref + 1; - int writtenRef = Write(newRef); + if (ref < 0) { + AI_LOG_FN_EXIT(); + return ref; + } - if (writtenRef < 0 || writtenRef > INT_MAX) - { - AI_LOG_ERROR("Invalid ref count returned from Write(): %d", writtenRef); - AI_LOG_FN_EXIT(); - return -1; - } - AI_LOG_DEBUG("ref count: %d", writtenRef); + if (ref >= INT_MAX) { + AI_LOG_ERROR("Reference count overflow at INT_MAX"); + AI_LOG_FN_EXIT(); + return -1; + } + + int newRef = ref + 1; + + int writtenRef = Write(newRef); + if (writtenRef < 0 || writtenRef > INT_MAX) { + AI_LOG_ERROR("Invalid ref count returned from Write(): %d", writtenRef); + AI_LOG_FN_EXIT(); + return -1; } + AI_LOG_DEBUG("ref count: %d", writtenRef); AI_LOG_FN_EXIT(); return writtenRef; } From 60aac7c7aaeb979f3e8e3a84927991543d957d3f Mon Sep 17 00:00:00 2001 From: dkumar798_comcast Date: Thu, 22 Jan 2026 11:51:57 +0000 Subject: [PATCH 10/28] RDKEMW-12282: Fix Coverity identified issues - dobby --- .../Common/source/ThreadedDispatcher.cpp | 2 +- bundle/lib/source/DobbyRootfs.cpp | 17 +++- client/tool/source/Main.cpp | 82 ++++++++-------- plugins/OpenCDM/source/OpenCDMPlugin.cpp | 72 +++++++------- rdkPlugins/Networking/source/IPAllocator.cpp | 34 +++---- rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp | 12 +-- .../Storage/source/DynamicMountDetails.cpp | 95 ++++++++++--------- rdkPlugins/Storage/source/RefCountFile.cpp | 9 +- 8 files changed, 178 insertions(+), 145 deletions(-) diff --git a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp index 56637caad..5f294fbd8 100644 --- a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp +++ b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp @@ -135,6 +135,7 @@ void ThreadedDispatcher::flush() std::unique_lock runningLocker(m); if(running) { + runningLocker.unlock(); std::mutex flushMutex; std::condition_variable flushCond; bool flushed = false; @@ -153,7 +154,6 @@ void ThreadedDispatcher::flush() flushCond.notify_one(); }); - runningLocker.unlock(); while (!flushed) { flushCond.wait(locker); } diff --git a/bundle/lib/source/DobbyRootfs.cpp b/bundle/lib/source/DobbyRootfs.cpp index 4e6820625..3cc873ba7 100644 --- a/bundle/lib/source/DobbyRootfs.cpp +++ b/bundle/lib/source/DobbyRootfs.cpp @@ -142,14 +142,23 @@ DobbyRootfs::DobbyRootfs(const std::shared_ptr& utils, } // check that rootfs exists in bundle - if (access(rootfsDirPath.c_str(), F_OK) == -1) + int dirFd = open(rootfsDirPath.c_str(), O_CLOEXEC | O_DIRECTORY); + if (dirFd == -1) { - AI_LOG_ERROR_EXIT("could not find rootfs at %s", rootfsDirPath.c_str()); - return; + if (errno == ENOENT) + { + AI_LOG_ERROR_EXIT("could not find rootfs at %s", rootfsDirPath.c_str()); + return; + } + else + { + AI_LOG_SYS_ERROR(errno, "failed to open rootfs directory '%s'", rootfsDirPath.c_str()); + return; + } } else { - mDirFd = open(rootfsDirPath.c_str(), O_CLOEXEC | O_DIRECTORY); + mDirFd = dirFd; } // store the complete path diff --git a/client/tool/source/Main.cpp b/client/tool/source/Main.cpp index 458d89d42..959e6273b 100644 --- a/client/tool/source/Main.cpp +++ b/client/tool/source/Main.cpp @@ -313,25 +313,14 @@ static void startCommand(const std::shared_ptr &dobbyProxy, int32_t cd; struct stat statbuf; - if (stat(path.c_str(), &statbuf) < 0) - { - readLine->printLnError("failed to stat '%s' (%d - %s)", - path.c_str(), errno, strerror(errno)); - return; - } - - // check if path points to a directory - if (S_ISDIR(statbuf.st_mode)) + // Replace stat + opendir TOCTOU by trying opendir() first. If opendir succeeds, + // treat as directory. If opendir fails with ENOTDIR, treat as file. If ENOENT, + // report missing path. Other errors are reported as opendir errors. + DIR *d = opendir(path.c_str()); + if (d != nullptr) { // path points to a directory check that the path contains a config file struct dirent *dir; - DIR *d = opendir(path.c_str()); - if (d == nullptr) - { - readLine->printLnError("failed to opendir '%s' (%d - %s)", - path.c_str(), errno, strerror(errno)); - return; - } bool configFound = false; while ((dir = readdir(d)) != nullptr) { @@ -354,37 +343,54 @@ static void startCommand(const std::shared_ptr &dobbyProxy, } else { -#if defined(LEGACY_COMPONENTS) - // Path does not point to a directory, check that the file in path has - // a '.json' filename extension. - if (path.find(".json") == std::string::npos) + int opendirErr = errno; + if (opendirErr == ENOENT) { - readLine->printLnError("please provide the path to a bundle or a " - "valid .json file"); + readLine->printLnError("failed to stat '%s' (%d - %s)", + path.c_str(), opendirErr, strerror(opendirErr)); return; } - - std::ifstream file(path, std::ifstream::binary); - if (!file) + else if (opendirErr == ENOTDIR) { - readLine->printLnError("failed to open '%s'", args[1].c_str()); - return; - } + // Path does not point to a directory; treat as file/spec path +#if defined(LEGACY_COMPONENTS) + // Path does not point to a directory, check that the file in path has + // a '.json' filename extension. + if (path.find(".json") == std::string::npos) + { + readLine->printLnError("please provide the path to a bundle or a " + "valid .json file"); + return; + } + + std::ifstream file(path, std::ifstream::binary); + if (!file) + { + readLine->printLnError("failed to open '%s'", args[1].c_str()); + return; + } - file.seekg(0, std::ifstream::end); - ssize_t length = file.tellg(); - file.seekg(0, std::ifstream::beg); + file.seekg(0, std::ifstream::end); + ssize_t length = file.tellg(); + file.seekg(0, std::ifstream::beg); - char *buffer = new char[length]; - file.read(buffer, length); + char *buffer = new char[length]; + file.read(buffer, length); - std::string jsonSpec(buffer, length); - delete[] buffer; - cd = dobbyProxy->startContainerFromSpec(id, jsonSpec, files, command, displaySocketPath, envVars); + std::string jsonSpec(buffer, length); + delete[] buffer; + cd = dobbyProxy->startContainerFromSpec(id, jsonSpec, files, command, displaySocketPath, envVars); #else - readLine->printLnError("please provide the path to a bundle directory"); - return; + readLine->printLnError("please provide the path to a bundle directory"); + return; #endif // defined(LEGACY_COMPONENTS) + } + else + { + readLine->printLnError("failed to opendir '%s' (%d - %s)", + path.c_str(), opendirErr, strerror(opendirErr)); + return; + } } if (cd < 0) diff --git a/plugins/OpenCDM/source/OpenCDMPlugin.cpp b/plugins/OpenCDM/source/OpenCDMPlugin.cpp index 13a45b105..62f82912c 100644 --- a/plugins/OpenCDM/source/OpenCDMPlugin.cpp +++ b/plugins/OpenCDM/source/OpenCDMPlugin.cpp @@ -145,21 +145,34 @@ bool OpenCDMPlugin::postConstruction(const ContainerId& id, const std::string ocdmSocketPath("/tmp/ocdm"); // sanity check the socket exists - if it doesn't then we don't mount - if (access(ocdmSocketPath.c_str(), F_OK) != 0) + // (Attempt operations directly and treat ENOENT as "missing socket") + if (chmod(ocdmSocketPath.c_str(), S_IRWXU | S_IRGRP | S_IWGRP) != 0) { - AI_LOG_ERROR("missing '%s' socket, not mounting in container", - ocdmSocketPath.c_str()); + if (errno == ENOENT) + { + AI_LOG_ERROR("missing '%s' socket, not mounting in container", ocdmSocketPath.c_str()); + } + else + { + AI_LOG_SYS_ERROR(errno, "failed to change access on socket"); + // Stricter behavior: do not attempt chown or addMount if chmod failed. + // This prevents proceeding when we couldn't set expected permissions. + } } else { - if (chmod(ocdmSocketPath.c_str(), S_IRWXU | S_IRGRP | S_IWGRP) != 0) - AI_LOG_SYS_ERROR(errno, "failed to change access on socket"); + // chmod succeeded, proceed with chown and mount only if chown also succeeds if (chown(ocdmSocketPath.c_str(), 0, mAppsGroupId) != 0) + { AI_LOG_SYS_ERROR(errno, "failed to change owner off socket"); - - // mount the socket within the container - if (!startupState->addMount(ocdmSocketPath, ocdmSocketPath, "bind", mountFlags)) - AI_LOG_ERROR("failed to add bind mount for '%s'", ocdmSocketPath.c_str()); + // Stricter behavior: do not attempt to mount if chown failed. + } + else + { + // mount the socket within the container + if (!startupState->addMount(ocdmSocketPath, ocdmSocketPath, "bind", mountFlags)) + AI_LOG_ERROR("failed to add bind mount for '%s'", ocdmSocketPath.c_str()); + } } // on newer builds we may also need the /tmp/OCDM directory @@ -245,34 +258,29 @@ bool OpenCDMPlugin::writeFileIfNotExists(const std::string &filePath) const { AI_LOG_FN_ENTRY(); - // if the file already exists, don't bother recreating it - int fileExists = access(filePath.c_str(), R_OK); - - // file doesn't exist, so lets create it - if (fileExists < 0) + // Atomically attempt to create the file; if it exists, do nothing + int fd = open(filePath.c_str(), O_CLOEXEC | O_CREAT | O_EXCL | O_WRONLY, 0660); + if (fd >= 0) { - // create the file if doesn't exist - int fd = open(filePath.c_str(), O_CLOEXEC | O_CREAT | O_WRONLY, 0660); - if (fd < 0) - { - AI_LOG_SYS_ERROR(errno, "failed to create file @ '%s'", filePath.c_str()); - } - else - { - // set permissions to chmod 0660 and owner root:30000 - if (fchmod(fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) != 0) - AI_LOG_SYS_ERROR(errno, "failed to change access on '%s''", filePath.c_str()); - if (fchown(fd, 0, mAppsGroupId) != 0) - AI_LOG_SYS_ERROR(errno, "failed to change owner off '%s''", filePath.c_str()); - if (close(fd) != 0) - AI_LOG_SYS_ERROR(errno, "failed to close file @ '%s'", filePath.c_str()); - } + // Set file permissions and ownership + if (fchmod(fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) != 0) + AI_LOG_SYS_ERROR(errno, "Could not set permissions for '%s'", filePath.c_str()); + if (fchown(fd, 0, mAppsGroupId) != 0) + AI_LOG_SYS_ERROR(errno, "Could not set owner for '%s'", filePath.c_str()); + if (close(fd) != 0) + AI_LOG_SYS_ERROR(errno, "Could not close file '%s'", filePath.c_str()); AI_LOG_FN_EXIT(); return true; } - - AI_LOG_INFO("%s already exists, skipping creation", filePath.c_str()); + else if (errno == EEXIST) + { + AI_LOG_INFO("File '%s' already present, skipping creation", filePath.c_str()); + } + else + { + AI_LOG_SYS_ERROR(errno, "Unable to create file '%s'", filePath.c_str()); + } AI_LOG_FN_EXIT(); return false; diff --git a/rdkPlugins/Networking/source/IPAllocator.cpp b/rdkPlugins/Networking/source/IPAllocator.cpp index bfc78fbcb..5c24d0f78 100644 --- a/rdkPlugins/Networking/source/IPAllocator.cpp +++ b/rdkPlugins/Networking/source/IPAllocator.cpp @@ -225,29 +225,29 @@ bool IPAllocator::getContainerIpsFromDisk() mAllocatedIps.clear(); // Dir doesn't exist, no containers have run yet - struct stat buf; - if (stat(ADDRESS_FILE_DIR, &buf) != 0) + DIR *dir = opendir(ADDRESS_FILE_DIR); + if (!dir) { - // Create directory we will store IPs in - if (!mUtils->mkdirRecursive(ADDRESS_FILE_DIR, 0644)) + if (errno == ENOENT) + { + // Create directory we will store IPs in + if (!mUtils->mkdirRecursive(ADDRESS_FILE_DIR, 0644)) + { + AI_LOG_ERROR_EXIT("Failed to create dir @ '%s'", ADDRESS_FILE_DIR); + return false; + } + + AI_LOG_FN_EXIT(); + return true; + } + else { - AI_LOG_ERROR_EXIT("Failed to create dir @ '%s'", ADDRESS_FILE_DIR); + AI_LOG_SYS_ERROR_EXIT(errno, "Failed to open directory @ '%s'", ADDRESS_FILE_DIR); return false; } - - AI_LOG_FN_EXIT(); - return true; } // Work out what IPs are currently allocated to what containers - DIR *dir = opendir(ADDRESS_FILE_DIR); - if (!dir) - { - AI_LOG_SYS_ERROR_EXIT(errno, "Failed to open directory @ '%s", ADDRESS_FILE_DIR); - closedir(dir); - return -1; - } - // Each container gets a file in the store directory // Filename = container ID // Contents = ipaddress/veth @@ -312,4 +312,4 @@ std::string IPAllocator::ipAddressToString(const in_addr_t &ipAddress) AI_LOG_DEBUG("Converted IP %u -> %s", ipAddress, str); return std::string(str); -} \ No newline at end of file +} diff --git a/rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp b/rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp index 6d0bc5a46..3bae16db4 100644 --- a/rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp +++ b/rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp @@ -131,17 +131,17 @@ bool OOMCrash::postHalt() } std::string crashFile = path + "/oom_crashed_" + mUtils->getContainerId() + ".txt"; - if (stat(crashFile.c_str(), &buffer) == 0) + if (remove(crashFile.c_str()) != 0) { - if (remove(crashFile.c_str()) != 0) + if (errno != ENOENT) { perror("Failed to remove crash file"); AI_LOG_WARN("Could not remove crash file: %s (%d - %s)", crashFile.c_str(), errno, strerror(errno)); } - else - { - AI_LOG_INFO("%s file removed", crashFile.c_str()); - } + } + else + { + AI_LOG_INFO("%s file removed", crashFile.c_str()); } } diff --git a/rdkPlugins/Storage/source/DynamicMountDetails.cpp b/rdkPlugins/Storage/source/DynamicMountDetails.cpp index 2a93f2a87..9d893d5e0 100644 --- a/rdkPlugins/Storage/source/DynamicMountDetails.cpp +++ b/rdkPlugins/Storage/source/DynamicMountDetails.cpp @@ -135,49 +135,60 @@ bool DynamicMountDetails::onCreateContainer() const if (stat(mMountProperties.source.c_str(), &buffer) == 0) { bool isDir = S_ISDIR(buffer.st_mode); - if (stat(targetPath.c_str(), &buffer) != 0) + + std::string dirPath; + // Determine path based on whether target is a directory or file + if (isDir) { - std::string dirPath; - // Determine path based on whether target is a directory or file - if (isDir) - { - dirPath = targetPath; - } + dirPath = targetPath; + } + else + { + // Mounting a file so exclude filename from directory path + std::size_t found = targetPath.find_last_of("/"); + if (found == std::string::npos) + dirPath = "."; else - { - // Mounting a file so exclude filename from directory path - std::size_t found = targetPath.find_last_of("/"); dirPath = targetPath.substr(0, found); - } + } + + // Recursively create destination directory structure + bool prepareOk = true; + if (!mUtils->mkdirRecursive(dirPath, 0755) && (errno != EEXIST)) + { + AI_LOG_SYS_ERROR(errno, "failed to create mount destination path '%s' in storage plugin", targetPath.c_str()); + prepareOk = false; + } - // Recursively create destination directory structure - if (mUtils->mkdirRecursive(dirPath, 0755) || (errno == EEXIST)) + if (prepareOk && !isDir) + { + // If mounting a file, make sure a file with the same name + // exists at the desination path prior to bind mounting. + // Otherwise the bind mount may fail if the destination path + // filesystem is read-only. + // Creating the file first ensures an inode exists for the + // bind mount to target. + int fd = open(targetPath.c_str(), O_CLOEXEC | O_CREAT | O_WRONLY, 0644); + if (fd >= 0) { - if (!isDir) - { - // If mounting a file, make sure a file with the same name - // exists at the desination path prior to bind mounting. - // Otherwise the bind mount may fail if the destination path - // filesystem is read-only. - // Creating the file first ensures an inode exists for the - // bind mount to target. - int fd = open(targetPath.c_str(), O_RDONLY | O_CREAT, 0644); - if (fd >= 0) - { - close(fd); - } - else - { - AI_LOG_SYS_ERROR(errno, "failed to open or create destination '%s'", targetPath.c_str()); - } - } + close(fd); + // file creation succeeded (or opened existing file), continue } else { - AI_LOG_SYS_ERROR(errno, "failed to create mount destination path '%s' in storage plugin", targetPath.c_str()); + AI_LOG_SYS_ERROR(errno, "failed to open or create destination '%s'", targetPath.c_str()); + prepareOk = false; } } - success = addMount(); + + if (prepareOk) + { + success = addMount(); + } + else + { + success = false; + } } else { @@ -202,24 +213,20 @@ bool DynamicMountDetails::onPostStop() const bool success = false; std::string targetPath = mRootfsPath + mMountProperties.destination; - struct stat buffer; - if (stat(targetPath.c_str(), &buffer) == 0) + if (remove(targetPath.c_str()) == 0) { - if (remove(targetPath.c_str()) == 0) - { - success = true; - } - else - { - AI_LOG_SYS_ERROR(errno, "failed to remove dynamic mount '%s' in storage plugin", targetPath.c_str()); - } + success = true; } - else + else if (errno == ENOENT) { success = true; AI_LOG_INFO("Mount '%s' does not exist, dynamic mount skipped", targetPath.c_str()); } + else + { + AI_LOG_SYS_ERROR(errno, "failed to remove dynamic mount '%s' in storage plugin", targetPath.c_str()); + } AI_LOG_FN_EXIT(); return success; diff --git a/rdkPlugins/Storage/source/RefCountFile.cpp b/rdkPlugins/Storage/source/RefCountFile.cpp index ab7fb2ea1..2c016f5b1 100644 --- a/rdkPlugins/Storage/source/RefCountFile.cpp +++ b/rdkPlugins/Storage/source/RefCountFile.cpp @@ -109,12 +109,14 @@ int RefCountFile::Increment() int ref = Read(); - if (ref < 0) { + if (ref < 0) + { AI_LOG_FN_EXIT(); return ref; } - if (ref >= INT_MAX) { + if (ref >= INT_MAX) + { AI_LOG_ERROR("Reference count overflow at INT_MAX"); AI_LOG_FN_EXIT(); return -1; @@ -123,7 +125,8 @@ int RefCountFile::Increment() int newRef = ref + 1; int writtenRef = Write(newRef); - if (writtenRef < 0 || writtenRef > INT_MAX) { + if (writtenRef < 0) + { AI_LOG_ERROR("Invalid ref count returned from Write(): %d", writtenRef); AI_LOG_FN_EXIT(); return -1; From 06a0de355975aa33a5acbab6e74e1a161866eef3 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Fri, 23 Jan 2026 06:41:46 +0530 Subject: [PATCH 11/28] Update ThreadedDispatcher.cpp --- .../Common/source/ThreadedDispatcher.cpp | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp index 5f294fbd8..d2f738930 100644 --- a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp +++ b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp @@ -129,42 +129,40 @@ void ThreadedDispatcher::sync() */ void ThreadedDispatcher::flush() { - //To ensure all the work that is in the queue is done, we lock a mutex. - //post a job to the queue that signals completion via condition variable. - //Then block here until that's done. - std::unique_lock runningLocker(m); - if(running) { - runningLocker.unlock(); - std::mutex flushMutex; - std::condition_variable flushCond; - bool flushed = false; + std::unique_lock runningLocker(m); + if (!running) { + AI_LOG_WARN("This dispatcher is no longer running. Ignoring flush request."); + return; + } + } - std::unique_lock locker(flushMutex); - post([&]() { - { - std::lock_guard lock(flushMutex); - flushed = true; - } + std::mutex flushMutex; + std::condition_variable flushCond; + bool flushed = false; - { - std::lock_guard runningLock(m); - running = false; - } - flushCond.notify_one(); - }); + std::unique_lock locker(flushMutex); + post([&]() { + { + std::lock_guard lock(flushMutex); + flushed = true; + } - while (!flushed) { - flushCond.wait(locker); + { + std::lock_guard runningLock(m); + running = false; } - stop(); - } - else - { - AI_LOG_WARN("This dispatcher is no longer running. Ignoring flush request."); + flushCond.notify_one(); + }); + + while (!flushed) { + flushCond.wait(locker); } + + stop(); } + /** * @brief Cancels any work that is not already in progress, stop accepting new work */ From f6adb025cc875f4930a57b556691a5f20f70b0e6 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Fri, 23 Jan 2026 07:18:09 +0530 Subject: [PATCH 12/28] Update Notifier.h --- AppInfrastructure/Public/Common/Notifier.h | 1 + 1 file changed, 1 insertion(+) diff --git a/AppInfrastructure/Public/Common/Notifier.h b/AppInfrastructure/Public/Common/Notifier.h index a4c64ae3c..c81c36caf 100644 --- a/AppInfrastructure/Public/Common/Notifier.h +++ b/AppInfrastructure/Public/Common/Notifier.h @@ -185,6 +185,7 @@ class Notifier : virtual public Polymorphic { // We are unregistering an observer so make sure we will not notify unregistered observers lock.unlock(); + /* coverity[missing_lock : FALSE] */ dispatcher->sync(); lock.lock(); } From b39b46479a35154261e7ea972fb99aba4ebe28ca Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Fri, 23 Jan 2026 07:19:51 +0530 Subject: [PATCH 13/28] Update DobbyManager.cpp --- daemon/lib/source/DobbyManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/daemon/lib/source/DobbyManager.cpp b/daemon/lib/source/DobbyManager.cpp index 337d9e868..928db9cfc 100644 --- a/daemon/lib/source/DobbyManager.cpp +++ b/daemon/lib/source/DobbyManager.cpp @@ -3421,6 +3421,7 @@ bool DobbyManager::invalidContainerCleanupTask() mRunc->killCont(it->first, SIGKILL, true); // Did we actually kill it? Give it some time, then check the status + /* coverity[sleep : FALSE] */ std::this_thread::sleep_for(std::chrono::milliseconds(200)); DobbyRunC::ContainerStatus state = mRunc->state(it->first); From c1c6dbdccc02675686f22827f67ac200643505b2 Mon Sep 17 00:00:00 2001 From: dkumar798_comcast Date: Fri, 23 Jan 2026 07:28:24 +0000 Subject: [PATCH 14/28] RDKEMW-12282: Fix Coverity identified issues - dobby --- .../Common/source/ThreadedDispatcher.cpp | 52 ++++++++--------- bundle/lib/include/DobbyBundleConfig.h | 4 +- bundle/lib/source/DobbyBundleConfig.cpp | 4 +- daemon/lib/source/DobbyLogger.cpp | 2 +- plugins/Common/source/ServiceMonitor.cpp | 58 +++++++++++-------- 5 files changed, 61 insertions(+), 59 deletions(-) diff --git a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp index d2f738930..a896e07eb 100644 --- a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp +++ b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp @@ -124,43 +124,37 @@ void ThreadedDispatcher::sync() } } +namespace +{ +void unlockAndSetFlagToFalse(std::mutex& m, bool& flag) +{ + using namespace std; + m.unlock(); + flag = false; +} +} /** * @brief Perform any work remaining in the queue, then stop accepting new work. */ void ThreadedDispatcher::flush() { + //To ensure all the work that is in the queue is done, we lock a mutex. + //post a job to the queue that unlocks it and stops running further jobs. + //Then block here until that's done. + if(running) { - std::unique_lock runningLocker(m); - if (!running) { - AI_LOG_WARN("This dispatcher is no longer running. Ignoring flush request."); - return; - } + std::mutex m2; + m2.lock(); + post(bind(unlockAndSetFlagToFalse, std::ref(m2), std::ref(this->running))); + /* coverity[lock : FALSE] */ + m2.lock(); + m2.unlock(); + stop(); } - - std::mutex flushMutex; - std::condition_variable flushCond; - bool flushed = false; - - std::unique_lock locker(flushMutex); - post([&]() { - { - std::lock_guard lock(flushMutex); - flushed = true; - } - - { - std::lock_guard runningLock(m); - running = false; - } - - flushCond.notify_one(); - }); - - while (!flushed) { - flushCond.wait(locker); + else + { + AI_LOG_WARN("This dispatcher is no longer running. Ignoring flush request."); } - - stop(); } /** diff --git a/bundle/lib/include/DobbyBundleConfig.h b/bundle/lib/include/DobbyBundleConfig.h index d751b881c..623919164 100644 --- a/bundle/lib/include/DobbyBundleConfig.h +++ b/bundle/lib/include/DobbyBundleConfig.h @@ -73,13 +73,13 @@ class DobbyBundleConfig : public DobbyConfig bool restartOnCrash() const override; public: - const std::string& rootfsPath() const override; + std::string& rootfsPath() const override; public: std::shared_ptr config() const override; public: - const std::map& rdkPlugins() const override; + std::map& rdkPlugins() const override; #if defined(LEGACY_COMPONENTS) public: diff --git a/bundle/lib/source/DobbyBundleConfig.cpp b/bundle/lib/source/DobbyBundleConfig.cpp index a5bc8d7e9..da5c1ca00 100644 --- a/bundle/lib/source/DobbyBundleConfig.cpp +++ b/bundle/lib/source/DobbyBundleConfig.cpp @@ -239,7 +239,7 @@ void DobbyBundleConfig::setUidGidMappings(uid_t userId, gid_t groupId) mGroupId = groupId; } -const std::string& DobbyBundleConfig::rootfsPath() const +std::string& DobbyBundleConfig::rootfsPath() const { std::lock_guard locker(mLock); return mRootfsPath; @@ -288,7 +288,7 @@ const std::map& DobbyBundleConfig::legacyPlugins() con } #endif //defined(LEGACY_COMPONENTS) -const std::map& DobbyBundleConfig::rdkPlugins() const +std::map& DobbyBundleConfig::rdkPlugins() const { std::lock_guard locker(mLock); return mRdkPlugins; diff --git a/daemon/lib/source/DobbyLogger.cpp b/daemon/lib/source/DobbyLogger.cpp index 4302763a7..e53271094 100644 --- a/daemon/lib/source/DobbyLogger.cpp +++ b/daemon/lib/source/DobbyLogger.cpp @@ -116,7 +116,7 @@ DobbyLogger::~DobbyLogger() AI_LOG_FN_EXIT(); } catch (const std::exception& e) { - AI_LOG_SYS_ERROR(errno, "Caught Exception in ~DobbyLogger: %s", e.what()); + AI_LOG_ERROR(errno, "Caught Exception in ~DobbyLogger: %s", e.what()); } } diff --git a/plugins/Common/source/ServiceMonitor.cpp b/plugins/Common/source/ServiceMonitor.cpp index 86498334b..68ab790d8 100644 --- a/plugins/Common/source/ServiceMonitor.cpp +++ b/plugins/Common/source/ServiceMonitor.cpp @@ -148,31 +148,36 @@ void ServiceMonitor::onServiceNotification(bool added) { AI_LOG_INFO("%s service %s", mServiceName.c_str(), added ? "added" : "removed"); - std::unique_lock locker(mLock); - - State newState = mState; + State newState = State::NotRunning; + std::function handler; - if (added) { - // move our internal state to running, this is not the same as 'ready' - // which we expect to receive shortly - if (mState == State::NotRunning) - newState = State::Running; - } - else - { - newState = State::NotRunning; - } + std::unique_lock locker(mLock); + + newState = mState; + + if (added) + { + // move our internal state to running, this is not the same as 'ready' + // which we expect to receive shortly + if (mState == State::NotRunning) + newState = State::Running; + } + else + { + newState = State::NotRunning; + } - // call the registered handler - if (newState != mState) - { - mState = newState; - - - if (mStateChangeHandler) - mStateChangeHandler(newState); + // call the registered handler + if (newState != mState) + { + mState = newState; + handler = mStateChangeHandler; + } } + + if (handler) + handler(newState); } // ----------------------------------------------------------------------------- @@ -214,14 +219,17 @@ void ServiceMonitor::onReadyNotification(const AI_IPC::VariantList& args) bool ServiceMonitor::onTimer() { // take the lock and check if we think the daemon isn't there - std::unique_lock locker(mLock); - - if (mState != State::Ready) { + std::unique_lock locker(mLock); - sendIsReadyRequest(); + if (mState == State::Ready) + { + return true; + } } + sendIsReadyRequest(); + return true; } From 27308840ca1f9d451f23e48bee48626f25332628 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Fri, 23 Jan 2026 13:00:05 +0530 Subject: [PATCH 15/28] Update ThreadedDispatcher.cpp --- AppInfrastructure/Common/source/ThreadedDispatcher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp index a896e07eb..382bf79ae 100644 --- a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp +++ b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp @@ -147,7 +147,7 @@ void ThreadedDispatcher::flush() m2.lock(); post(bind(unlockAndSetFlagToFalse, std::ref(m2), std::ref(this->running))); /* coverity[lock : FALSE] */ - m2.lock(); + m2.lock(); m2.unlock(); stop(); } From e0d2038546a3229eac8c86f56f0180b302360ffe Mon Sep 17 00:00:00 2001 From: dkumar798_comcast Date: Fri, 23 Jan 2026 07:38:15 +0000 Subject: [PATCH 16/28] RDKEMW-12282: Fix Coverity identified issues - dobby --- bundle/lib/include/DobbyBundleConfig.h | 4 ++-- bundle/lib/source/DobbyBundleConfig.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bundle/lib/include/DobbyBundleConfig.h b/bundle/lib/include/DobbyBundleConfig.h index 623919164..de053e0fc 100644 --- a/bundle/lib/include/DobbyBundleConfig.h +++ b/bundle/lib/include/DobbyBundleConfig.h @@ -73,13 +73,13 @@ class DobbyBundleConfig : public DobbyConfig bool restartOnCrash() const override; public: - std::string& rootfsPath() const override; + const std::string& rootfsPath() const override; public: std::shared_ptr config() const override; public: - std::map& rdkPlugins() const override; + const std::map& rdkPlugins() const override; #if defined(LEGACY_COMPONENTS) public: diff --git a/bundle/lib/source/DobbyBundleConfig.cpp b/bundle/lib/source/DobbyBundleConfig.cpp index da5c1ca00..f9cc101db 100644 --- a/bundle/lib/source/DobbyBundleConfig.cpp +++ b/bundle/lib/source/DobbyBundleConfig.cpp @@ -239,7 +239,7 @@ void DobbyBundleConfig::setUidGidMappings(uid_t userId, gid_t groupId) mGroupId = groupId; } -std::string& DobbyBundleConfig::rootfsPath() const +const std::string& DobbyBundleConfig::rootfsPath() const { std::lock_guard locker(mLock); return mRootfsPath; @@ -263,6 +263,7 @@ IDobbyIPCUtils::BusType DobbyBundleConfig::sessionDbus() const IDobbyIPCUtils::BusType DobbyBundleConfig::debugDbus() const { + E return mDebugDbus; } @@ -288,7 +289,7 @@ const std::map& DobbyBundleConfig::legacyPlugins() con } #endif //defined(LEGACY_COMPONENTS) -std::map& DobbyBundleConfig::rdkPlugins() const +const std::map& DobbyBundleConfig::rdkPlugins() const { std::lock_guard locker(mLock); return mRdkPlugins; From ad315d1d8fe26d760250f6c38f682a0987d482b8 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Fri, 23 Jan 2026 13:11:34 +0530 Subject: [PATCH 17/28] Update DobbyBundleConfig.cpp --- bundle/lib/source/DobbyBundleConfig.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/bundle/lib/source/DobbyBundleConfig.cpp b/bundle/lib/source/DobbyBundleConfig.cpp index f9cc101db..a5bc8d7e9 100644 --- a/bundle/lib/source/DobbyBundleConfig.cpp +++ b/bundle/lib/source/DobbyBundleConfig.cpp @@ -263,7 +263,6 @@ IDobbyIPCUtils::BusType DobbyBundleConfig::sessionDbus() const IDobbyIPCUtils::BusType DobbyBundleConfig::debugDbus() const { - E return mDebugDbus; } From a495ad95f6f02e0c382b0d914e03815207cbcce7 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Fri, 23 Jan 2026 13:15:55 +0530 Subject: [PATCH 18/28] Update DobbyLogger.cpp --- daemon/lib/source/DobbyLogger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/lib/source/DobbyLogger.cpp b/daemon/lib/source/DobbyLogger.cpp index e53271094..4302763a7 100644 --- a/daemon/lib/source/DobbyLogger.cpp +++ b/daemon/lib/source/DobbyLogger.cpp @@ -116,7 +116,7 @@ DobbyLogger::~DobbyLogger() AI_LOG_FN_EXIT(); } catch (const std::exception& e) { - AI_LOG_ERROR(errno, "Caught Exception in ~DobbyLogger: %s", e.what()); + AI_LOG_SYS_ERROR(errno, "Caught Exception in ~DobbyLogger: %s", e.what()); } } From f5138f928b404ec63b1c0d7731a0a3f32cbaf4ca Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Fri, 23 Jan 2026 14:55:54 +0530 Subject: [PATCH 19/28] Update DobbyTemplate.cpp --- bundle/lib/source/DobbyTemplate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundle/lib/source/DobbyTemplate.cpp b/bundle/lib/source/DobbyTemplate.cpp index 8e7b7499c..6146d3b63 100644 --- a/bundle/lib/source/DobbyTemplate.cpp +++ b/bundle/lib/source/DobbyTemplate.cpp @@ -537,7 +537,7 @@ std::string DobbyTemplate::_apply(const ctemplate::TemplateDictionaryInterface* if (!mTemplateCache->ExpandNoLoad(mTemplateKey, prettyPrint ? ctemplate::STRIP_WHITESPACE - : ctemplate::DO_NOT_STRIP, + : ctemplate::STRIP_WHITESPACE, dictionary, nullptr, &result)) { AI_LOG_ERROR("template cache expand on load failed"); @@ -655,7 +655,7 @@ bool DobbyTemplate::_applyAt(int dirFd, const std::string& fileName, bool success = mTemplateCache->ExpandNoLoad(mTemplateKey, prettyPrint ? ctemplate::STRIP_WHITESPACE : - ctemplate::DO_NOT_STRIP, + ctemplate::STRIP_WHITESPACE, dictionary, nullptr, &emitter); if (!success) { From b7d7f2fa124994b2f0be7c2bc66cace06089ff76 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Wed, 4 Feb 2026 12:13:41 +0530 Subject: [PATCH 20/28] Update ThreadedDispatcher.cpp --- .../Common/source/ThreadedDispatcher.cpp | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp index 382bf79ae..f4d598389 100644 --- a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp +++ b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp @@ -40,19 +40,18 @@ ThreadedDispatcher::ThreadedDispatcher(int priority, const std::string& name /*= } void ThreadedDispatcher::post(std::function work) { - std::unique_lock lock(m); - if(running) - { + {std::unique_lock lock(m); + if(!running) + { + AI_LOG_WARN("Ignoring work because the dispatcher is not running anymore"); + return; + //can't throw an exception here because if this is executed from destructor, + //which occurs when work adds more work things go horribly wrong. + //Instead, ignore work. + } q.push_back(work); - cv.notify_one(); - } - else - { - AI_LOG_WARN("Ignoring work because the dispatcher is not running anymore"); - //can't throw an exception here because if this is executed from destructor, - //which occurs when work adds more work things go horribly wrong. - //Instead, ignore work. } + cv.notify_one(); } namespace { @@ -70,8 +69,9 @@ namespace */ void syncCallback(std::mutex* lock, std::condition_variable* cond, bool* fired) { - std::unique_lock locker(*lock); - *fired = true; + {std::unique_lock locker(*lock); + *fired = true; + } cond->notify_all(); } } // namespace @@ -107,14 +107,15 @@ void ThreadedDispatcher::sync() std::condition_variable cond; bool fired = false; // Take the queue lock and ensure we're still running - std::unique_lock qlocker(m); - if (!running) - { - AI_LOG_DEBUG("Ignoring sync because dispatcher is not running"); - return; + {std::unique_lock qlocker(m); + if (!running) + { + AI_LOG_DEBUG("Ignoring sync because dispatcher is not running"); + return; + } + // Add the work object to the queue which takes the lock and sets 'fired' to true + q.push_back(std::bind(syncCallback, &lock, &cond, &fired)); } - // Add the work object to the queue which takes the lock and sets 'fired' to true - q.push_back(std::bind(syncCallback, &lock, &cond, &fired)); cv.notify_one(); // Wait for 'fired' to become true std::unique_lock locker(lock); @@ -146,7 +147,7 @@ void ThreadedDispatcher::flush() std::mutex m2; m2.lock(); post(bind(unlockAndSetFlagToFalse, std::ref(m2), std::ref(this->running))); - /* coverity[lock : FALSE] */ + // coverity[double_lock : FALSE] m2.lock(); m2.unlock(); stop(); @@ -162,8 +163,9 @@ void ThreadedDispatcher::flush() */ void ThreadedDispatcher::stop() { - std::unique_lock lock(m); - running = false; + {std::unique_lock lock(m); + running = false; + } cv.notify_one(); t.join(); } From 03f92fe93bea52b9c9592e6a3bdf515f3f986fc6 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Wed, 4 Feb 2026 13:05:39 +0530 Subject: [PATCH 21/28] Update ServiceMonitor.cpp --- plugins/Common/source/ServiceMonitor.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/Common/source/ServiceMonitor.cpp b/plugins/Common/source/ServiceMonitor.cpp index 68ab790d8..52c1f6884 100644 --- a/plugins/Common/source/ServiceMonitor.cpp +++ b/plugins/Common/source/ServiceMonitor.cpp @@ -194,19 +194,21 @@ void ServiceMonitor::onServiceNotification(bool added) void ServiceMonitor::onReadyNotification(const AI_IPC::VariantList& args) { AI_LOG_INFO("%s service is ready", mServiceName.c_str()); + bool notify = false; - std::unique_lock locker(mLock); + {std::unique_lock locker(mLock); - if (mState != State::Ready) - { - // set the state back to ready - mState = State::Ready; - - - // call the registered handler - if (mStateChangeHandler) - mStateChangeHandler(State::Ready); + if (mState != State::Ready) + { + // set the state back to ready + mState = State::Ready; + notify = true; + } } + + // call the registered handler + if (notify && mStateChangeHandler) + mStateChangeHandler(State::Ready); } // ----------------------------------------------------------------------------- From 9756d4a8e53fb1a7ceedf1eb359de5f95c6bef60 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Wed, 4 Feb 2026 14:07:08 +0530 Subject: [PATCH 22/28] Update ThreadedDispatcher.cpp --- AppInfrastructure/Common/source/ThreadedDispatcher.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp index f4d598389..b7e397639 100644 --- a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp +++ b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp @@ -178,7 +178,6 @@ ThreadedDispatcher::~ThreadedDispatcher() } bool ThreadedDispatcher::hasMoreWorkOrWasStopRequested() { - std::unique_lock lock(m); return !q.empty() || !running; } void ThreadedDispatcher::doWork(const std::string& name, int priority) From dc87f41015a15477675f53b34f63c32082a1b82a Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Wed, 4 Feb 2026 15:05:56 +0530 Subject: [PATCH 23/28] Update DobbyBundleConfig.cpp --- bundle/lib/source/DobbyBundleConfig.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/bundle/lib/source/DobbyBundleConfig.cpp b/bundle/lib/source/DobbyBundleConfig.cpp index a5bc8d7e9..965394470 100644 --- a/bundle/lib/source/DobbyBundleConfig.cpp +++ b/bundle/lib/source/DobbyBundleConfig.cpp @@ -241,7 +241,6 @@ void DobbyBundleConfig::setUidGidMappings(uid_t userId, gid_t groupId) const std::string& DobbyBundleConfig::rootfsPath() const { - std::lock_guard locker(mLock); return mRootfsPath; } @@ -290,7 +289,6 @@ const std::map& DobbyBundleConfig::legacyPlugins() con const std::map& DobbyBundleConfig::rdkPlugins() const { - std::lock_guard locker(mLock); return mRdkPlugins; } From 2077a4e8d6d104a695684a778bb8785d47c26db6 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Wed, 4 Feb 2026 16:58:24 +0530 Subject: [PATCH 24/28] Update DobbyProxy.cpp --- client/lib/source/DobbyProxy.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/lib/source/DobbyProxy.cpp b/client/lib/source/DobbyProxy.cpp index 9fbb6f67d..a98ce8602 100644 --- a/client/lib/source/DobbyProxy.cpp +++ b/client/lib/source/DobbyProxy.cpp @@ -134,8 +134,9 @@ DobbyProxy::~DobbyProxy() // can now safely stop the dispatcher thread if (mStateChangeThread.joinable()) { - std::unique_lock locker(mStateChangeLock); - mStateChangeQueue.emplace_back(StateChangeEvent::Terminate); + {std::unique_lock locker(mStateChangeLock); + mStateChangeQueue.emplace_back(StateChangeEvent::Terminate); + } mStateChangeCond.notify_all(); mStateChangeThread.join(); From 572c7b305cbfaef43e1a480607fb7fcae26bb927 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Thu, 5 Feb 2026 20:36:56 +0530 Subject: [PATCH 25/28] Update DobbyIpcBus.cpp --- ipcUtils/source/DobbyIpcBus.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ipcUtils/source/DobbyIpcBus.cpp b/ipcUtils/source/DobbyIpcBus.cpp index d7dedc464..4ba9fae0b 100644 --- a/ipcUtils/source/DobbyIpcBus.cpp +++ b/ipcUtils/source/DobbyIpcBus.cpp @@ -61,8 +61,9 @@ DobbyIpcBus::~DobbyIpcBus() // set the terminate flag and wake the thread if (mServiceChangeThread.joinable()) { - std::unique_lock locker(mLock); - mServiceChangeQueue.emplace_back(ServiceChangeEvent::Terminate); + {std::unique_lock locker(mLock); + mServiceChangeQueue.emplace_back(ServiceChangeEvent::Terminate); + } mServiceChangeCond.notify_all(); mServiceChangeThread.join(); From 9efbfb97c52d06070600fa39dd58068d9bf909ea Mon Sep 17 00:00:00 2001 From: DineshkumarJP Date: Fri, 6 Feb 2026 09:13:09 +0530 Subject: [PATCH 26/28] Fixed the alignement --- .../Common/include/ConditionVariable.h | 2 +- .../Common/source/ThreadedDispatcher.cpp | 14 ++--- .../source/sdbus/SDBusIpcService.cpp | 10 +-- bundle/lib/source/DobbyBundleConfig.cpp | 6 +- bundle/lib/source/DobbyConfig.cpp | 2 +- bundle/tool/source/Main.cpp | 2 +- daemon/lib/source/Dobby.cpp | 62 ++++++++----------- daemon/lib/source/DobbyManager.cpp | 2 +- .../source/MulticastSocketsPlugin.cpp | 2 +- rdkPlugins/Minidump/source/AnonymousFile.cpp | 10 +-- rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp | 2 +- settings/source/Settings.cpp | 2 +- 12 files changed, 53 insertions(+), 63 deletions(-) diff --git a/AppInfrastructure/Common/include/ConditionVariable.h b/AppInfrastructure/Common/include/ConditionVariable.h index 470bf54f3..bdadad576 100644 --- a/AppInfrastructure/Common/include/ConditionVariable.h +++ b/AppInfrastructure/Common/include/ConditionVariable.h @@ -181,7 +181,7 @@ class ConditionVariable { return std::cv_status::no_timeout; } - else if (err == ETIMEDOUT) + else if (err == ETIMEDOUT) { return std::cv_status::timeout; } diff --git a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp index b7e397639..f9011ff83 100644 --- a/AppInfrastructure/Common/source/ThreadedDispatcher.cpp +++ b/AppInfrastructure/Common/source/ThreadedDispatcher.cpp @@ -40,7 +40,7 @@ ThreadedDispatcher::ThreadedDispatcher(int priority, const std::string& name /*= } void ThreadedDispatcher::post(std::function work) { - {std::unique_lock lock(m); + {std::unique_lock lock(m); if(!running) { AI_LOG_WARN("Ignoring work because the dispatcher is not running anymore"); @@ -48,7 +48,7 @@ void ThreadedDispatcher::post(std::function work) //can't throw an exception here because if this is executed from destructor, //which occurs when work adds more work things go horribly wrong. //Instead, ignore work. - } + } q.push_back(work); } cv.notify_one(); @@ -69,7 +69,7 @@ namespace */ void syncCallback(std::mutex* lock, std::condition_variable* cond, bool* fired) { - {std::unique_lock locker(*lock); + {std::unique_lock locker(*lock); *fired = true; } cond->notify_all(); @@ -83,7 +83,7 @@ bool ThreadedDispatcher::invokedFromDispatcherThread() bool res = (std::this_thread::get_id() == t.get_id()); if (res) { - std::stringstream ss; + std::stringstream ss; ss << "Caller thread Id [" << std::this_thread::get_id() << "] == [dispatcher thread Id " << t.get_id() << "]"; AI_LOG_ERROR("%s", ss.str().c_str()); } @@ -107,7 +107,7 @@ void ThreadedDispatcher::sync() std::condition_variable cond; bool fired = false; // Take the queue lock and ensure we're still running - {std::unique_lock qlocker(m); + {std::unique_lock qlocker(m); if (!running) { AI_LOG_DEBUG("Ignoring sync because dispatcher is not running"); @@ -148,7 +148,7 @@ void ThreadedDispatcher::flush() m2.lock(); post(bind(unlockAndSetFlagToFalse, std::ref(m2), std::ref(this->running))); // coverity[double_lock : FALSE] - m2.lock(); + m2.lock(); m2.unlock(); stop(); } @@ -163,7 +163,7 @@ void ThreadedDispatcher::flush() */ void ThreadedDispatcher::stop() { - {std::unique_lock lock(m); + {std::unique_lock lock(m); running = false; } cv.notify_one(); diff --git a/AppInfrastructure/IpcService/source/sdbus/SDBusIpcService.cpp b/AppInfrastructure/IpcService/source/sdbus/SDBusIpcService.cpp index 54c9e82ab..e80ee8313 100644 --- a/AppInfrastructure/IpcService/source/sdbus/SDBusIpcService.cpp +++ b/AppInfrastructure/IpcService/source/sdbus/SDBusIpcService.cpp @@ -180,9 +180,9 @@ SDBusIpcService::~SDBusIpcService() // invoke the quit lambda if (!runOnEventLoopThread(std::move(quitExec))) - { - AI_LOG_ERROR("Failed to post quitExec to event loop thread"); - } + { + AI_LOG_ERROR("Failed to post quitExec to event loop thread"); + } // wait for the thread to quit @@ -344,8 +344,8 @@ bool SDBusIpcService::stop() if (!runOnEventLoopThread(std::move(nopExec))) { - AI_LOG_ERROR("Failed to queue noop event on event loop thread"); - } + AI_LOG_ERROR("Failed to queue noop event on event loop thread"); + } return true; diff --git a/bundle/lib/source/DobbyBundleConfig.cpp b/bundle/lib/source/DobbyBundleConfig.cpp index 965394470..8516298ae 100644 --- a/bundle/lib/source/DobbyBundleConfig.cpp +++ b/bundle/lib/source/DobbyBundleConfig.cpp @@ -81,9 +81,9 @@ DobbyBundleConfig::DobbyBundleConfig(const std::shared_ptr& utils, std::string postInstallPath = bundlePath + "/postinstallhooksuccess"; if (remove(postInstallPath.c_str()) != 0) - { - AI_LOG_ERROR("Failed to remove postinstallhooksuccess"); - } + { + AI_LOG_ERROR("Failed to remove postinstallhooksuccess"); + } // Retry creation of config diff --git a/bundle/lib/source/DobbyConfig.cpp b/bundle/lib/source/DobbyConfig.cpp index 2fe6d47f7..67de32c96 100644 --- a/bundle/lib/source/DobbyConfig.cpp +++ b/bundle/lib/source/DobbyConfig.cpp @@ -558,7 +558,7 @@ bool DobbyConfig::writeConfigJsonImpl(const std::string& filePath) const // set file permissions if (chmod(filePath.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0) { - AI_LOG_SYS_WARN(errno, "Failed to set permissions on config file '%s'", filePath.c_str()); + AI_LOG_SYS_WARN(errno, "Failed to set permissions on config file '%s'", filePath.c_str()); } diff --git a/bundle/tool/source/Main.cpp b/bundle/tool/source/Main.cpp index ac789742e..86a66c1f8 100644 --- a/bundle/tool/source/Main.cpp +++ b/bundle/tool/source/Main.cpp @@ -285,5 +285,5 @@ int main(int argc, char *argv[]) } catch (const std::exception& e) { AI_LOG_ERROR_EXIT("Unhandled exception in main: %s\n", e.what()); exit(EXIT_FAILURE); - } + } } diff --git a/daemon/lib/source/Dobby.cpp b/daemon/lib/source/Dobby.cpp index 2188ac605..414533b82 100644 --- a/daemon/lib/source/Dobby.cpp +++ b/daemon/lib/source/Dobby.cpp @@ -1211,13 +1211,11 @@ void Dobby::stop(std::shared_ptr replySender) // Fire off the reply if (!replySender->sendReply({ result })) - { - AI_LOG_ERROR("Failed to send reply from stop lambda"); - } - - }; + { + AI_LOG_ERROR("Failed to send reply from stop lambda"); + } - // Queue the work, if successful then we're done + }; // Queue the work, if successful then we're done if (mWorkQueue->postWork(std::move(doStopLambda))) { AI_LOG_FN_EXIT(); @@ -1269,13 +1267,11 @@ void Dobby::pause(std::shared_ptr replySender) // Fire off the reply if (!replySender->sendReply({ result })) - { - AI_LOG_ERROR("Failed to send reply from pause lambda"); - } - - }; + { + AI_LOG_ERROR("Failed to send reply from pause lambda"); + } - // Queue the work, if successful then we're done + }; // Queue the work, if successful then we're done if (mWorkQueue->postWork(std::move(doPauseLambda))) { AI_LOG_FN_EXIT(); @@ -1717,8 +1713,8 @@ void Dobby::exec(std::shared_ptr replySender) auto doExecLambda = [manager = mManager, descriptor, - options = std::move(options), - command = std::move(command), + options = std::move(options), + command = std::move(command), replySender]() { @@ -1783,9 +1779,9 @@ void Dobby::getState(std::shared_ptr replySender) // Fire off the reply if (!replySender->sendReply({ result })) - { - AI_LOG_ERROR("Failed to send reply from getState lambda"); - } + { + AI_LOG_ERROR("Failed to send reply from getState lambda"); + } }; @@ -1872,13 +1868,11 @@ void Dobby::getInfo(std::shared_ptr replySender) // Fire off the reply if (!replySender->sendReply({ result })) - { - AI_LOG_ERROR("Failed to send reply from getState lambda"); - } - - }; + { + AI_LOG_ERROR("Failed to send reply from getState lambda"); + } - // Queue the work, if successful then we're done + }; // Queue the work, if successful then we're done if (mWorkQueue->postWork(std::move(doGetInfoLambda))) { AI_LOG_FN_EXIT(); @@ -1889,7 +1883,7 @@ void Dobby::getInfo(std::shared_ptr replySender) // Fire off an error reply if (!replySender->sendReply({ "" })) { - AI_LOG_ERROR("Failed to send fallback reply from getInfo"); + AI_LOG_ERROR("Failed to send fallback reply from getInfo"); } @@ -1933,13 +1927,11 @@ void Dobby::list(std::shared_ptr replySender) } // Fire off the reply if (!replySender->sendReply({ cds, ids })) - { - AI_LOG_ERROR("Failed to send reply from list lambda"); - } - - }; + { + AI_LOG_ERROR("Failed to send reply from list lambda"); + } - // Queue the work, if successful then we're done + }; // Queue the work, if successful then we're done if (mWorkQueue->postWork(std::move(doListLambda))) { AI_LOG_FN_EXIT(); @@ -2108,13 +2100,11 @@ void Dobby::getOCIConfig(std::shared_ptr replySender) // Fire off the reply if (!replySender->sendReply({ configJson })) - { - AI_LOG_ERROR("Failed to send reply from getOCIConfig lambda"); - } - - }; + { + AI_LOG_ERROR("Failed to send reply from getOCIConfig lambda"); + } - // Queue the work, if successful then we're done + }; // Queue the work, if successful then we're done if (mWorkQueue->postWork(std::move(doCreateBundleLambda))) { AI_LOG_FN_EXIT(); diff --git a/daemon/lib/source/DobbyManager.cpp b/daemon/lib/source/DobbyManager.cpp index 928db9cfc..39baa532f 100644 --- a/daemon/lib/source/DobbyManager.cpp +++ b/daemon/lib/source/DobbyManager.cpp @@ -517,7 +517,7 @@ void DobbyManager::cleanupContainersShutdown() // to avoid repeating indefinitely. It will be cleaned on boot-up mContainers.erase(eraseIt); AI_LOG_ERROR("Failed to stop container %s. Will attempt to clean up at daemon restart", id.c_str()); - } + } else { // This would normally be done async by the runc monitor thread, but we're diff --git a/plugins/MulticastSockets/source/MulticastSocketsPlugin.cpp b/plugins/MulticastSockets/source/MulticastSocketsPlugin.cpp index 307b0bb6b..548afa223 100644 --- a/plugins/MulticastSockets/source/MulticastSocketsPlugin.cpp +++ b/plugins/MulticastSockets/source/MulticastSocketsPlugin.cpp @@ -109,7 +109,7 @@ bool MulticastSocketPlugin::postConstruction(const ContainerId &id, if (socket < 0) { AI_LOG_ERROR("Failed to create server socket for container %s", id.c_str()); - return false; + return false; } int duppedSocket = startupState->addFileDescriptor(mName, socket); diff --git a/rdkPlugins/Minidump/source/AnonymousFile.cpp b/rdkPlugins/Minidump/source/AnonymousFile.cpp index d169cbf04..6aa4d4d22 100644 --- a/rdkPlugins/Minidump/source/AnonymousFile.cpp +++ b/rdkPlugins/Minidump/source/AnonymousFile.cpp @@ -133,7 +133,7 @@ bool AnonymousFile::copyContentTo(const std::string& destFile) if (fileSize <= 0) { AI_LOG_DEBUG("Empty or invalid file size %ld for fd %d", fileSize, mFd); - fclose(fp); + fclose(fp); fp = nullptr; AI_LOG_FN_EXIT(); return true; @@ -143,7 +143,7 @@ bool AnonymousFile::copyContentTo(const std::string& destFile) if (!buffer) { AI_LOG_SYS_ERROR_EXIT(errno, "failed to allocate buffer for reading fd %d", mFd); - fclose(fp); + fclose(fp); fp = nullptr; return false; } @@ -152,7 +152,7 @@ bool AnonymousFile::copyContentTo(const std::string& destFile) if (elementsRead != fileSize) { AI_LOG_ERROR_EXIT("failed to read fd %d correctly", mFd); - fclose(fp); + fclose(fp); fp = nullptr; free(buffer); return false; @@ -164,7 +164,7 @@ bool AnonymousFile::copyContentTo(const std::string& destFile) if (strncmp(buffer, "MDMP", 4) != 0) { AI_LOG_WARN("Incorrect file header for fd %d", mFd); - fclose(fp); + fclose(fp); fp = nullptr; free(buffer); AI_LOG_FN_EXIT(); @@ -175,7 +175,7 @@ bool AnonymousFile::copyContentTo(const std::string& destFile) if (destFd == -1) { AI_LOG_ERROR_EXIT("Cannot open %s", destFile.c_str()); - fclose(fp); + fclose(fp); fp = nullptr; free(buffer); return false; diff --git a/rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp b/rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp index 3bae16db4..c09f96cca 100644 --- a/rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp +++ b/rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp @@ -54,7 +54,7 @@ unsigned OOMCrash::hookHints() const { return ( IDobbyRdkPlugin::HintFlags::PostInstallationFlag | - IDobbyRdkPlugin::HintFlags::PostHaltFlag); + IDobbyRdkPlugin::HintFlags::PostHaltFlag); } /** diff --git a/settings/source/Settings.cpp b/settings/source/Settings.cpp index 8e84d04ab..d88cae521 100644 --- a/settings/source/Settings.cpp +++ b/settings/source/Settings.cpp @@ -232,7 +232,7 @@ Settings::Settings(const Json::Value& settings) else if(pluginName.isObject()) { for (const auto& value : pluginName.getMemberNames()) - { + { mDefaultPlugins.push_back(value); mRdkPluginsData[value] = pluginName[value]; } From 39319d78db261ddcb259e53bcd4e8a782ebdb945 Mon Sep 17 00:00:00 2001 From: DineshkumarJP Date: Fri, 6 Feb 2026 09:30:24 +0530 Subject: [PATCH 27/28] Fixed the alignement --- daemon/lib/source/DobbyManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/lib/source/DobbyManager.cpp b/daemon/lib/source/DobbyManager.cpp index 39baa532f..6a08373fb 100644 --- a/daemon/lib/source/DobbyManager.cpp +++ b/daemon/lib/source/DobbyManager.cpp @@ -517,7 +517,7 @@ void DobbyManager::cleanupContainersShutdown() // to avoid repeating indefinitely. It will be cleaned on boot-up mContainers.erase(eraseIt); AI_LOG_ERROR("Failed to stop container %s. Will attempt to clean up at daemon restart", id.c_str()); - } + } else { // This would normally be done async by the runc monitor thread, but we're From 8f338e47cdc74297564c4e501255a2c4261f630b Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Fri, 6 Feb 2026 09:40:22 +0530 Subject: [PATCH 28/28] Update Main.cpp --- bundle/tool/source/Main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bundle/tool/source/Main.cpp b/bundle/tool/source/Main.cpp index 86a66c1f8..3337011aa 100644 --- a/bundle/tool/source/Main.cpp +++ b/bundle/tool/source/Main.cpp @@ -282,8 +282,8 @@ int main(int argc, char *argv[]) // And we're done AICommon::termLogging(); return EXIT_SUCCESS; - } catch (const std::exception& e) { - AI_LOG_ERROR_EXIT("Unhandled exception in main: %s\n", e.what()); - exit(EXIT_FAILURE); + } catch (const std::exception& e) { + AI_LOG_ERROR_EXIT("Unhandled exception in main: %s\n", e.what()); + exit(EXIT_FAILURE); } }