68 Commits

Author SHA1 Message Date
Kovid Goyal
a2104d3755 Merge branch 'feat/10090-graphics-cache-dir' of https://github.com/Mekann2904/kitty 2026-06-19 10:16:10 +05:30
Kovid Goyal
ec2cc29de7 Dont expose method used only for testing to wider code 2026-06-19 07:28:52 +05:30
Matsumoto Kotaro
cc2d7a1789 graphics: add memory-only storage for graphics data
Add a new graphics protocol key, N=1, to request that transmitted
image/frame data is kept only in memory and not written to the graphics
disk cache file.

This is useful for transient high-frequency updates such as video-like
streams, where the latest frame is the only useful data and persisting
each frame to the disk cache causes unnecessary write traffic.

The implementation keeps the existing graphics cache abstraction intact:
memory-only entries can still be read back by animation, composition, and
frame coalescing paths. Only persistence to the disk cache file is skipped.

The default behavior is unchanged when N is omitted or set to zero.
2026-05-30 18:46:24 +09:00
Kovid Goyal
8eb76cd315 Fix #10037 2026-05-19 21:11:55 +05:30
Kovid Goyal
950497ac0c Cleanup previous PR 2026-04-03 22:25:05 +05:30
z3rco
b39f88c6a2 Fix multiple security vulnerabilities across C, Python, and Go code
Timing-safe comparisons:
- crypto.c: Replace memcmp with CRYPTO_memcmp for Secret equality,
  require equal lengths before comparing
- remote_control.py: Constant-time password lookup to avoid leaking
  valid passwords via dict hash timing
- file_transmission.py: Use hmac.compare_digest for bypass token
  comparison instead of ==

Memory safety:
- child-monitor.c: Fix inverted condition in write_to_peer that
  prevented memmove from ever executing on partial writes
- ibus_glfw.c: Null-terminate IBUS_ADDRESS copy to prevent string
  overread when strlen >= PATH_MAX
- x11_window.c: Add NULL checks after realloc in clipboard/DnD
  data handling (two sites)
- dnd.c: Cap accepted_mimes at 1MB to prevent unbounded growth,
  fix realloc to not lose the original pointer on failure
- png-reader.c: Cast to size_t before multiplication to prevent
  integer overflow on 32-bit platforms

Secrets hygiene:
- disk-cache.c: Zero encryption_key with explicit_bzero before free

Tar extraction hardening:
- tar.go: Validate hardlink targets against destination prefix to
  prevent writing outside extraction directory
- tar.go: Strip setuid/setgid/sticky bits from extracted files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 16:10:46 +01:00
Kovid Goyal
4ea6862dd3 Remove unused code 2025-11-17 17:23:40 +05:30
Kovid Goyal
1240a17b2d Disk cache: Do not encrypt disk cache contents when the disk cache file was opened with O_TMPFILE
Avoids paying the XOR overhead on all cached data. Temp files opened
using O_TMPFILE are secure enough, as far as I know. Processes without
elevated privileges cannot read from them unless they inherit the file
descriptor.
2025-11-17 14:30:15 +05:30
Kovid Goyal
e6d7e91000 Avoid using lseek() to track disk cache file write offset
It's slow and not thread safe.
We use pwrite() so it's not reliable anyway.
2025-11-17 11:16:30 +05:30
Kovid Goyal
2ba28171ab DRYer 2024-07-16 10:45:46 +05:30
Kovid Goyal
c056df223e Nicer way to prevent defrag 2024-07-16 07:43:50 +05:30
Kovid Goyal
56bd1f59dd cleanup must be called with lock held 2024-07-15 22:07:50 +05:30
Kovid Goyal
24e6dda0bc disk-cache: Improve hole management
Make coalescing of neighboring holes robust. Speed up hole finding.
Cost is we replace a single array tracking holes with three hashmaps
tracking size->[pos] pos->size and endpos->size.
2024-07-15 21:13:59 +05:30
Kovid Goyal
aaf7808328 Add explicit check for holes in test 2024-07-15 09:05:44 +05:30
Kovid Goyal
7d685fc98b Getting size of cache file should not change its position 2024-07-12 11:45:48 +05:30
Kovid Goyal
6958803fec Add some locking to python disk cache test API 2024-07-12 11:45:48 +05:30
Kovid Goyal
53eff7927a Migrate disk cache to verstable 2024-07-12 11:45:45 +05:30
Kovid Goyal
2d18e0be81 Fix #7311 2024-04-05 20:00:08 +05:30
Kovid Goyal
c3869dc479 ... 2024-03-01 11:07:51 +05:30
Kovid Goyal
1a9a7a59ac Make XOR64 test also test alignment issues 2024-02-25 09:57:44 +05:30
Kovid Goyal
ad3ab877f8 Use a fast SIMD implementation to XOR data going into the disk cache 2024-02-25 09:57:43 +05:30
Kovid Goyal
88f3c8c5ee Reduce max key size in disk cache
We used only 12 byte keys no need to have a max key size more than 16
2024-02-25 09:57:43 +05:30
Kovid Goyal
de92470f0d Improve performance of disk cache when there are thousands of small images
Fixes #7080
2024-02-25 09:57:43 +05:30
Kovid Goyal
b560fe34c9 Give the functions for creating various objects unique names so they are easily recognized in macOS's non-fully-symolicated crash reports 2024-02-25 09:57:37 +05:30
Kovid Goyal
6c7a8f8fa9 Ensure usage of __attribute__(cleanup) never frees un-initialized memory
Use macros that take an initializer parameter to, thereby ensuring the
variable to be cleaned up is always initialized.
2023-08-07 12:24:18 +05:30
Kovid Goyal
c004fd1f4d Declare the set of handled signals in only one place 2022-06-05 08:01:26 +05:30
Kovid Goyal
bd21b79959 Only malloc the buffer for fast file copy when needed 2021-11-24 18:20:37 +05:30
Kovid Goyal
732ff7ee58 Move copy between files into its own module 2021-11-24 16:42:52 +05:30
Kovid Goyal
f081d6a421 Fix #4270 2021-11-24 16:37:27 +05:30
Kovid Goyal
b25ea9c863 Fix #3913 2021-08-09 08:37:53 +05:30
Kovid Goyal
be34af4555 Remove inline from .c files
It is ignored by compilers and hides unused static functions
2021-08-03 09:11:17 +05:30
Kovid Goyal
f3364cfdc0 Guard against invalid cache file in a couple more places 2021-05-13 09:51:57 +05:30
Kovid Goyal
ec68739585 Make it harder to forget to redefine uthash_fatal 2021-05-07 06:58:54 +05:30
Kovid Goyal
dd0130180b Use the kitty fatal function 2021-05-06 11:19:06 +05:30
Kovid Goyal
fc184984a0 ... 2021-04-27 15:11:34 +05:30
Kovid Goyal
2178ff1c48 DRYer 2021-04-27 15:07:27 +05:30
Kovid Goyal
ae1df38c88 Fallback to mkostemp if O_TMPFILE fails 2021-04-27 12:03:24 +05:30
Kovid Goyal
7ec803222f Fix a mem leak of the disk cache directory path 2021-04-10 13:21:58 +05:30
Kovid Goyal
2a96d2621c Use cleanup in a few more places to simplify the code 2021-02-19 18:53:30 +05:30
Kovid Goyal
12604072fc Allow querying number cached in ram from c code as well 2021-02-19 09:28:56 +05:30
Kovid Goyal
0341b64748 Allow caching of disk cache entries in RAM 2021-02-18 10:22:42 +05:30
Kovid Goyal
726d736aac Type check return value of cache_dir 2021-02-05 10:34:17 +05:30
Kovid Goyal
0adbbc6d62 Implement loading of frame animation data 2021-01-31 20:58:41 +05:30
Kovid Goyal
5a182d3d13 Store image data in a disk cache 2021-01-31 20:58:41 +05:30
Kovid Goyal
d55fde9eea Use EINTR safe wrappers for open() and shm_open() 2021-01-31 07:02:11 +05:30
Kovid Goyal
2762488c81 Remove double increment 2021-01-03 21:10:37 +05:30
Kovid Goyal
1b59a1c421 Finish tests of disk cache 2021-01-03 17:36:40 +05:30
Kovid Goyal
df00e9545d Add some more ensure_state() 2021-01-03 12:13:08 +05:30
Kovid Goyal
d1496f1eb5 Use O_TMPFILE when available 2021-01-03 07:07:50 +05:30
Kovid Goyal
14d9bcb08a Go back to nanosleep since it is in POSIX 2021-01-03 06:45:53 +05:30