You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2025/08/20 05:36:33 UTC

(logging-log4cxx) 01/01: Prevent SonarCloud failure

This is an automated email from the ASF dual-hosted git repository.

swebb2066 pushed a commit to branch silence_sonar_cloud
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git

commit 3c8cf8934730ea3e098ba7b9a18dbd43650b4f33
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Wed Aug 20 15:36:12 2025 +1000

    Prevent SonarCloud failure
---
 src/main/cpp/system.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/main/cpp/system.cpp b/src/main/cpp/system.cpp
index 423c0136..e12efc4d 100644
--- a/src/main/cpp/system.cpp
+++ b/src/main/cpp/system.cpp
@@ -146,8 +146,15 @@ void System::addProgramFilePathComponents(Properties& props)
 #elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)
 	std::ostringstream exeLink;
 	exeLink << "/proc/" << getpid() << "/exe";
-	bufCount = readlink(exeLink.str().c_str(), buf, bufSize);
-	if (0 < bufCount)
+	if ((bufCount = readlink(exeLink.str().c_str(), buf, bufSize)) <= 0)
+	{
+		LOG4CXX_DECODE_CHAR(lsExeLink, exeLink.str());
+		LogLog::error(LOG4CXX_STR("Failed to read ") + lsExeLink);
+		return;
+	}
+	if (bufSize < bufCount)
+		buf[bufSize] = 0;
+	else
 		buf[bufCount] = 0;
 #else
 	LogLog::warn(LOG4CXX_STR("Unable to determine the name of the executable file on this system"));