This is an automated email from the ASF dual-hosted git repository.
FreeAndNil pushed a commit to branch Feature/AVSS-Fixes
in repository https://gitbox.apache.org/repos/asf/logging-log4net.git
The following commit(s) were added to refs/heads/Feature/AVSS-Fixes by this
push:
new 43d24247 Fix mutex leak in InterProcessLock.AcquireLock when file
stream is null Release acquired mutex and decrement recursiveWatch when stream
is null to prevent indefinite blocking of other processes (CWE-772)
43d24247 is described below
commit 43d24247b7e32839efb6e0e5b06a56570b919d6c
Author: Jan Friedrich <[email protected]>
AuthorDate: Sun Jun 21 23:24:52 2026 +0200
Fix mutex leak in InterProcessLock.AcquireLock when file stream is null
Release acquired mutex and decrement recursiveWatch when stream is null to
prevent indefinite blocking of other processes (CWE-772)
---
src/changelog/3.3.2/298-fix-interprocesslock-mutex-leak.xml | 11 +++++++++++
src/log4net/Appender/FileAppender.cs | 3 +++
2 files changed, 14 insertions(+)
diff --git a/src/changelog/3.3.2/298-fix-interprocesslock-mutex-leak.xml
b/src/changelog/3.3.2/298-fix-interprocesslock-mutex-leak.xml
new file mode 100644
index 00000000..7d4f2630
--- /dev/null
+++ b/src/changelog/3.3.2/298-fix-interprocesslock-mutex-leak.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="https://logging.apache.org/xml/ns"
+ xsi:schemaLocation="https://logging.apache.org/xml/ns
https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
+ type="fixed">
+ <issue id="f57d7b3-002"
link="https://github.com/apache/tooling-agents/blob/main/ASVS/reports/logging-log4net/f57d7b3/issues.md#issue-finding-002---interprocesslock-mutex-not-released-when-underlying-file-stream-is-null"/>
+ <issue id="298" link="https://github.com/apache/logging-log4net/pull/298"/>
+ <description format="asciidoc">
+ fix mutex leak in `InterProcessLock.AcquireLock` when the underlying file
stream is null (CWE-772)
+ </description>
+</entry>
diff --git a/src/log4net/Appender/FileAppender.cs
b/src/log4net/Appender/FileAppender.cs
index 22c35881..5b444afd 100644
--- a/src/log4net/Appender/FileAppender.cs
+++ b/src/log4net/Appender/FileAppender.cs
@@ -657,6 +657,9 @@ public override void CloseFile()
else
{
// this can happen when the file appender cannot open a file for
writing
+ _recursiveWatch--;
+ _mutex.ReleaseMutex();
+ return null;
}
}
else