about summary refs log tree commit diff stats
path: root/src/utils
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-06-27 21:50:31 +0200
committerbptato <nincsnevem662@gmail.com>2024-06-28 21:26:33 +0200
commit8268ba2cf049be1865875e3e01305a500fa533e2 (patch)
tree7ce60624f9212e65dad0c1a2d168eb6ab7c03ec9 /src/utils
parentf9734e2b3900781901bb5f268137bd9adbfc33ef (diff)
downloadchawan-8268ba2cf049be1865875e3e01305a500fa533e2.tar.gz
img, loader: add image resizing, misc fixes
* resize images with stb_image_resize
* use tee for output handle redirection (redirectToFile blocks)
* cache original image files
* accept lseek in sandbox
* misc stbi fixes

For now, I just pulled in stb_image_resize v1. v2 is an extra 150K in
size, not sure if it's worth the cost. (Either way, we can always switch
later if needed, since the API is almost the same.)

Next step: move sixel/kitty encoders to CGI, and cache their output in
memory instead of the intermediate RGBA representation.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/sandbox.nim2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/utils/sandbox.nim b/src/utils/sandbox.nim
index ce9b194e..d4312a49 100644
--- a/src/utils/sandbox.nim
+++ b/src/utils/sandbox.nim
@@ -89,6 +89,7 @@ elif defined(linux) and not disableSandbox:
       "getrlimit", # glibc uses it after fork it seems
       "getsockname", # Nim needs it for connecting
       "gettimeofday", # used by QuickJS in Date.now()
+      "lseek", # glibc calls lseek on open files at exit
       "mmap", # memory allocation
       "mmap2", # memory allocation
       "mremap", # memory allocation
@@ -131,6 +132,7 @@ elif defined(linux) and not disableSandbox:
     const allowList = [
       cstring"close", "exit_group", # duh
       "read", "write", "recv", "send", "recvfrom", "sendto", # socket i/o
+      "lseek", # glibc calls lseek on open files at exit
       "fcntl", "fcntl64", # so we can set nonblock etc.
       "mmap", "mmap2", "mremap", "munmap", "brk", # memory allocation
       "poll", # curl needs poll