about summary refs log tree commit diff stats
path: root/src/bindings
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-09-04 20:10:19 +0200
committerbptato <nincsnevem662@gmail.com>2024-09-04 20:42:35 +0200
commit412a78efc4eff3ea2b73f79cba8baee97cba9f18 (patch)
treeec65615bab94174038a1103a3143535e4f07fc81 /src/bindings
parent9666c5a994830859a61078a1fabfef16b483c714 (diff)
downloadchawan-412a78efc4eff3ea2b73f79cba8baee97cba9f18.tar.gz
sixel, stbi, sandbox: fix fstat sandbox violation
Until recently, glibc used to implement it as fstatat. So don't trap
for fstatat (and for consistency, fstat), but return EPERM.

Just to be sure, rewrite sixel & stbi to never call fread.
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/libseccomp.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/bindings/libseccomp.nim b/src/bindings/libseccomp.nim
index 81a6e969..3f02e4d9 100644
--- a/src/bindings/libseccomp.nim
+++ b/src/bindings/libseccomp.nim
@@ -37,6 +37,9 @@ const SCMP_ACT_KILL_PROCESS* = 0x80000000u32
 const SCMP_ACT_ALLOW* = 0x7FFF0000u32
 const SCMP_ACT_TRAP* = 0x00030000u32
 
+template SCMP_ACT_ERRNO*(x: uint16): uint32 =
+  0x50000u32 or x
+
 proc seccomp_init*(def_action: uint32): scmp_filter_ctx
 proc seccomp_reset*(ctx: scmp_filter_ctx; def_action: uint32): cint
 proc seccomp_syscall_resolve_name*(name: cstring): cint