]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xz, xzdec: Capsicum sandbox: Fix incorrect use of cap_rights_clear() v5.6
authorGuillaume Outters <guillaume-installs@outters.eu>
Fri, 25 Apr 2025 00:55:08 +0000 (02:55 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Mon, 28 Apr 2025 15:20:16 +0000 (18:20 +0300)
cap_rights_clear() with no additional arguments acts as a no-op, so
instead of removing all capability rights from STDIN_FILENO, the same
rights were allowed for STDIN_FILENO as were allowed for src_fd.

Fixes: a0eecc235d3b ("xz: Make Capsicum sandbox more strict with stdin and stdout.")
(The commit message says "stdout". It should have said "stderr".)

(cherry picked from commit 5cc2e479eb447a444f5ab005fc36b7f275c75eb5)

src/xz/sandbox.c
src/xzdec/xzdec.c

index 5a12f69b65823eb62110dc81bf32df7b363acba6..1802f8dbeab9a8691fc001615c500b891d172c83 100644 (file)
@@ -319,7 +319,7 @@ sandbox_enable_strict_if_allowed(
 
        // If not reading from stdin, remove all capabilities from it.
        if (src_fd != STDIN_FILENO && cap_rights_limit(
-                       STDIN_FILENO, cap_rights_clear(&rights)))
+                       STDIN_FILENO, cap_rights_init(&rights)))
                goto error;
 
        if (cap_rights_limit(STDOUT_FILENO, cap_rights_init(&rights,
index d281e0711a5142416477ca4d3dbbf63b790ffa59..491707cc31e0c52a4957a9603e98bb1998550865 100644 (file)
@@ -316,7 +316,7 @@ sandbox_enter(int src_fd)
 
        // If not reading from stdin, remove all capabilities from it.
        if (src_fd != STDIN_FILENO && cap_rights_limit(
-                       STDIN_FILENO, cap_rights_clear(&rights)))
+                       STDIN_FILENO, cap_rights_init(&rights)))
                goto error;
 
        if (cap_rights_limit(STDOUT_FILENO, cap_rights_init(&rights,