DragonFlyBSD Kernel Audit
DF-2664 / fix.diff
← back to finding ↓ download raw
--- a/sys/vfs/hammer2/hammer2_lz4.c	2026-08-30 09:16:39.712999480 +0000
+++ b/sys/vfs/hammer2/hammer2_lz4.c	2026-08-30 09:16:39.724999328 +0000
@@ -406,6 +406,13 @@
     // targetOutputSize too large, better decode everything
     if unlikely(outputSize==0) goto _output_error;
     // Empty output buffer
+    if ((endOnInput) && unlikely(inputSize==0)) goto _output_error;
+    // Error : empty input stream.  A correctly formed null-compressed
+    // LZ4 stream must have at least one byte (token=0).  Without this
+    // guard the token fetch in the main loop reads one byte past the
+    // source buffer when inputSize==0.  Restores the upstream r96 /
+    // v1.9.4 guard dropped in the r97 reorganization this file was
+    // vendored from.
 
 
     // Main Loop