From e100580926cd14757b2492ab4cd86c6ff8a3db18 Mon Sep 17 00:00:00 2001 From: Karthick Swaminathan <85346280+ks734@users.noreply.github.com> Date: Tue, 3 Feb 2026 15:37:53 +0530 Subject: [PATCH 1/2] RDKEMW-10995: Proper fd validation --- rdkPlugins/Logging/source/FileSink.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/rdkPlugins/Logging/source/FileSink.cpp b/rdkPlugins/Logging/source/FileSink.cpp index 4beb5fe6b..44dec051e 100644 --- a/rdkPlugins/Logging/source/FileSink.cpp +++ b/rdkPlugins/Logging/source/FileSink.cpp @@ -77,7 +77,7 @@ FileSink::FileSink(const std::string &containerId, std::shared_ptr 0) + if (mDevNullFd >= 0) { mOutputFileFd = mDevNullFd; } @@ -88,17 +88,20 @@ FileSink::FileSink(const std::string &containerId, std::shared_ptr= 0 && mOutputFileFd != mDevNullFd) { - AI_LOG_SYS_ERROR(errno, "Failed to close /dev/null"); + if (close(mOutputFileFd) < 0) + { + AI_LOG_SYS_ERROR(errno, "Failed to close output file"); + } } - if (mOutputFileFd > 0) + if (mDevNullFd >= 0) { - if (close(mOutputFileFd) < 0) + if (close(mDevNullFd) < 0) { - AI_LOG_SYS_ERROR(errno, "Failed to close output file"); + AI_LOG_SYS_ERROR(errno, "Failed to close /dev/null"); } } } @@ -264,4 +267,4 @@ int FileSink::openFile(const std::string &pathName) } return openedFd; -} \ No newline at end of file +} From 6e47b9364479dbeb85119d7f8caaba21cd5feb1a Mon Sep 17 00:00:00 2001 From: Karthick Swaminathan <85346280+ks734@users.noreply.github.com> Date: Tue, 10 Feb 2026 15:10:45 +0530 Subject: [PATCH 2/2] RDKEMW-10995: Proper fd validation --- rdkPlugins/Logging/source/FileSink.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rdkPlugins/Logging/source/FileSink.cpp b/rdkPlugins/Logging/source/FileSink.cpp index 44dec051e..fdf3c8503 100644 --- a/rdkPlugins/Logging/source/FileSink.cpp +++ b/rdkPlugins/Logging/source/FileSink.cpp @@ -120,6 +120,11 @@ void FileSink::DumpLog(const int bufferFd) std::lock_guard locker(mLock); + if (mOutputFileFd < 0) { + AI_LOG_ERROR("Invalid output file descriptor"); + return; + } + ssize_t ret; ssize_t offset = 0;