You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2022/04/26 15:24:50 UTC

[commons-daemon] 07/08: Fix DAEMON-441. Avoid null pointer access if no log path is specified

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

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-daemon.git

commit 84e6046327863d44f9ec592e5bf9d335e767f040
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 26 15:15:20 2022 +0100

    Fix DAEMON-441. Avoid null pointer access if no log path is specified
    
    This is the primary cause of DAEMON-441. The other commits for this
    issue fixed various errors that masked this error to some degree.
---
 src/changes/changes.xml           |  4 ++++
 src/native/windows/src/security.c | 11 +++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4474e08..ed377a4 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -56,6 +56,10 @@
         Procrun. Clear logged error on service installation failure to prevent
         the error polluting subsequent log messages.
       </action>
+      <action issue="DAEMON-441" type="fix" dev="markt">
+        Procrun. When configuring permissions for the logging path, use the
+        default path if no explicit logging path is specified.
+      </action>
       <!-- UPDATES -->
       <action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">
         Bump actions/cache from 2.1.7 to 3.0.2 #41.
diff --git a/src/native/windows/src/security.c b/src/native/windows/src/security.c
index 5cfedff..a4ee87e 100644
--- a/src/native/windows/src/security.c
+++ b/src/native/windows/src/security.c
@@ -33,8 +33,15 @@ apxSecurityGrantFileAccessToUser(
     PSECURITY_DESCRIPTOR pSD;
     EXPLICIT_ACCESS ea;
 
-    lstrlcpyW(sPath, SIZ_PATHLEN, szPath);
-
+    if (szPath) { 
+        lstrlcpyW(sPath, SIZ_PATHLEN, szPath);
+    } else {
+        dwResult = GetSystemDirectoryW(sPath, MAX_PATH);
+        if (dwResult) {
+            return dwResult;
+        }
+        lstrlcatW(sPath, MAX_PATH, LOG_PATH_DEFAULT);
+    }
     if (szUser) {
         /* The API used to set file permissions doesn't always recognised the
          * same users as the API used to configured services. We do any