Commit Graph

23 Commits (main)

Author SHA1 Message Date
Jeffrey C. Ollie ec55cbc879
wuffs: protect against crafted images that cause overflows
Fixes #9579

Protect against panics caused by integer overflows by using functions
that allow integer overflows to be caught instead of causing a panic.

Also protect against DOS from images that might not cause an
overflow but do consume an absurd amount of memory by limiting
images to a maximum size of 4GiB (which is the maximum size of
`image-storage-limit`).
2025-11-13 14:20:19 -06:00
Mitchell Hashimoto 7ec57aeebd
Zig 0.15: zig fmt 2025-10-03 07:10:43 -07:00
Mitchell Hashimoto d02770d292
zig-15: build binary builds 2025-10-03 07:10:41 -07:00
Jeffrey C. Ollie 3cce5d26d7
wuffs: simplify the build 2025-08-20 10:08:24 -05:00
Jayson Reis d5995ac45c
build-system: Replace deprecated usages of root_source_file on addTests 2025-07-23 00:03:44 +02:00
Qwerasd 03bdb92292 renderer: clean up `image.zig`, reduce repetitive code 2025-06-25 16:27:23 -04:00
Qwerasd df8dc33ab6 renderer: unify `image.zig`
The code in metal/image.zig and opengl/image.zig was virtually identical
save for the texture options, so I've moved that to the GraphicsAPI and
unified them in to renderer/image.zig
2025-06-23 13:12:17 -06:00
Mitchell Hashimoto 0f1860f066
build: use a libc txt file to point to correct Apple SDK
This fixes an issue where Ghostty would not build against the macOS 15.5 SDK.

What was happening was that Zig was adding its embedded libc paths to
the clang command line, which included old headers that were
incompatible with the latest (macOS 15.5) SDK. Ghostty was adding the
newer paths but they were being overridden by the embedded libc paths.

The reason this was happening is because Zig was using its own logic to
find the libc paths and this was colliding with the paths we were
setting manually. To fix this, we now use a `libc.txt` file that
explicitly tells Zig where to find libc, and we base this on our own SDK
search logic.
2025-05-29 15:04:05 -07:00
Mitchell Hashimoto cfea2ea12c
build: mark most dependencies as lazy
Lazy dependencies are only fetched if the build script would actually
reach a usage of that dependency at runtime (when the `lazyDependency`
function is called). This can save a lot of network traffic, disk uage,
and time because we don't have to fetch and build dependencies that we
don't actually need.

Prior to this commit, Ghostty fetched almost everything for all
platforms and configurations all the time. This commit reverses that to
fetching almost nothing until it's actually needed.

There are very little downsides to doing this[1]. One downside is `zig
build --fetch` doesn't fetch lazy dependencies, but we don't rely on
this command for packaging and suggest using our custom shell script
that downloads a cached list of URLs (`build.zig.zon.txt`).

This commit doesn't cover 100% of dependencies, since some provide no
benefit to make lazy while the complexity to make them lazy is higher
(in code style typically).

Conversely, some simple dependencies are marked lazy even if they're
almost always needed if they don't introduce any real complexity to the
code, because there is very little downside to do so.

[1]: https://ziggit.dev/t/lazy-dependencies-best-dependencies/5509/5
2025-03-14 13:32:19 -07:00
Mitchell Hashimoto bd848a27d2
update all packages to new hash for caching 2025-03-12 07:30:01 -07:00
Mitchell Hashimoto 7e2286eb8c
Zig 0.14 2025-03-11 14:39:04 -07:00
Mitchell Hashimoto 8231ebb770
build: mirror most of our direct dependencies
This adds a new script `update-mirror.sh` which generates the proper
blob format for R2 (or any blob storage) to mirror all of our
dependencies.

It doesn't automate updating build.zig.zon but on an ongoing basis this
should be easy to do manually, and we can strive to automate it in the
future.

I omitted iTerm2 color themes because we auto-update that via CI and
updating all of the machinery to send it to our mirror and so on is a
pain. Additionally, this doesn't mirror transitive dependencies because
Zig doesn't have a way to fetch those from a mirror instead (unless you
pre-generate a full cache like packagers but that's not practical for
day to day development).

It's hugely beneficial just to get most of our dependencies mirrored.
2025-02-14 10:06:15 -08:00
Jeffrey C. Ollie f32ad5216b build: generate a build.zig.zon.txt file for easy zig fetch scripting
This fixes a regression in 1.1.1/1.1.2 where our PACKAGING docs mention
using `fetch-zig-cache.sh` but it was removed. This commit adds it back,
generating its contents from the build.zig.zon file (via zon2nix which
we use for our Nix packaging).

For packagers, there are no dependency changes: you still need Zig and
POSIX sh. For release time, Ghostty has a new dependency on `jq` but
otherwise the release process is the same. The check-zig-cache.sh script
is updated to generate the new build.zig.zon.txt file.
2025-02-14 09:23:51 -08:00
Qwerasd c2da843dfd fix(wuffs): don't premul alpha when loading images
It seems like the raw data version of the kitty graphics transmit
operation is meant to be unassociated (aka straight) alpha, though I
can't find any definitive documentation either way- but in any case
unassociated alpha is more common in image formats and makes the
handling easier for the rest of it.

Also removed a redundant call to `decode_frame_config`, since it's
called implicitly when we call `decode_frame` right after.
2025-01-17 14:38:38 -05:00
Jeffrey C. Ollie 22c2fe9610
wuffs: use common struct to return decoded image data 2025-01-01 22:48:30 -06:00
Jeffrey C. Ollie 652079b26c
wuffs: update, add jpeg decoding, add simple tests 2025-01-01 22:48:30 -06:00
Jeffrey C. Ollie f2d53b451b
wuffs: fix blend mode 2024-09-04 18:23:54 -05:00
Mitchell Hashimoto 5f1c9dd0df
pkg/wuffs: use proper apple include paths on darwin targets 2024-09-02 21:02:36 -07:00
Mitchell Hashimoto 781a721fc7
pkg/wuffs: fix builds for 32-bit systems 2024-09-02 20:57:23 -07:00
Mitchell Hashimoto de612934a0
some tweaks for wuffs 2024-09-02 20:47:07 -07:00
Mitchell Hashimoto c6e187865a
pkg/wuffs: define build defines separately, not in defs.zig 2024-09-02 20:47:07 -07:00
Jeffrey C. Ollie d6e5c8e20f remove unnecessary @constCast 2024-09-02 20:47:07 -07:00
Jeffrey C. Ollie 6edeb45e7e kitty graphics: address review comments
- move wuffs code from src/ to pkg/
- eliminate stray debug logs
- make logs a warning instead of an error
- remove initialization of some structs to zero
2024-09-02 20:47:07 -07:00