Commit Graph

14939 Commits

Author SHA1 Message Date
Mitchell Hashimoto
2d69568a67 terminal: handle trailing colon in SGR underline parsing (#11113)
A trailing colon with no following sub-parameter (e.g. "ESC[58:4:m")
leaves the colon separator bit set on the last param without adding
another entry to the params array. When the SGR parser later iterates to
that param (4 = underline) and sees the colon bit, it entered the colon
path which asserted slice.len >= 2, but the slice only had one element.

Replace the assert with a bounds check that treats the malformed
sequence as a default single underline.

Add a regression test reproducing the crash from AFL++ fuzzing
(afl-out/stream/default/crashes/id:000021).

#11109
2026-03-01 15:38:28 -08:00
Mitchell Hashimoto
ec4c5f90a8 terminal: fix panic on CSI g (TBC) with overflowing param (#11112)
A fuzz crash found that CSI g with a parameter that saturates to u16 max
(65535) causes @enumFromInt to panic when narrowing to TabClear
(enum(u8)). Use std.meta.intToEnum instead, which safely returns an
error for out-of-range values.

#11109
2026-03-01 15:38:14 -08:00
Mitchell Hashimoto
f253c54fac terminal: handle trailing colon in SGR underline parsing
A trailing colon with no following sub-parameter (e.g. "ESC[58:4:m")
leaves the colon separator bit set on the last param without adding
another entry to the params array. When the SGR parser later iterates
to that param (4 = underline) and sees the colon bit, it entered the
colon path which asserted slice.len >= 2, but the slice only had one
element.

Replace the assert with a bounds check that treats the malformed
sequence as a default single underline.

Add a regression test reproducing the crash from AFL++ fuzzing
(afl-out/stream/default/crashes/id:000021).
2026-03-01 15:28:56 -08:00
Mitchell Hashimoto
a595c00f3c terminal: fix panic on CSI g (TBC) with overflowing param
A fuzz crash found that CSI g with a parameter that saturates to
u16 max (65535) causes @enumFromInt to panic when narrowing to
TabClear (enum(u8)). Use std.meta.intToEnum instead, which safely
returns an error for out-of-range values.
2026-03-01 15:15:27 -08:00
Mitchell Hashimoto
1ead8f4275 fuzz: terminal.vtStream fuzzer (#11109)
This augments our libghostty fuzzing to add fuzzing for
`terminal.vtStream` which exercises a LOT more codepaths than the pure
parser (thousands of tuples compared to hundreds with `afl-showmap` on
the two binaries). I also fixed up a few more minor things: prettier
ignores AFL related files, lib-vt exports the readonly streams, etc.
2026-03-01 15:08:47 -08:00
Mitchell Hashimoto
8cebcaa468 fuzz: stream cmin 2026-03-01 15:00:13 -08:00
Mitchell Hashimoto
dce2326c4c fix up gitattributes 2026-03-01 14:55:07 -08:00
Mitchell Hashimoto
1c65611446 prettier should ignore various fuzz files 2026-03-01 14:55:07 -08:00
Mitchell Hashimoto
33fbd73247 fuzz/stream: clean up 2026-03-01 14:55:07 -08:00
Mitchell Hashimoto
4f44879c3b Clean up how fuzzers are laid out 2026-03-01 14:55:07 -08:00
Mitchell Hashimoto
e081a4abb4 fuzz/vt-stream 2026-03-01 14:55:07 -08:00
Mitchell Hashimoto
1e027c9f20 terminal: insertBlanks should not crash with count 0 and CSI @ clamps to 1 min (#11111)
CSI @ (ICH) with an explicit parameter of 0 should be clamped to 1,
matching xterm behavior. Previously, a zero count reached
Terminal.insertBlanks which called clearCells with an empty slice,
triggering an out-of-bounds panic.

Fix the stream dispatch to clamp 0 to 1 via @max, and add a defensive
guard in insertBlanks for count == 0. Found by AFL++ stream fuzzer.
#11109
2026-03-01 14:54:56 -08:00
Mitchell Hashimoto
9157eb439a terminal: insertBlanks should not crash with count 0 and CSI @ clamps [1,)
CSI @ (ICH) with an explicit parameter of 0 should be clamped to 1,
matching xterm behavior. Previously, a zero count reached
Terminal.insertBlanks which called clearCells with an empty slice,
triggering an out-of-bounds panic.

Fix the stream dispatch to clamp 0 to 1 via @max, and add a defensive
guard in insertBlanks for count == 0. Found by AFL++ stream fuzzer.
2026-03-01 14:50:24 -08:00
Mitchell Hashimoto
8c22cb0601 terminal: fix out-of-bounds access in CSI W handler with no params (#11110)
CSI ? W (cursor tabulation control) accessed input.params[0] without
first checking that params.len > 0, causing an index out-of-bounds panic
when the sequence had an intermediate but no parameters.

Add a params.len == 1 guard before accessing params[0].

Found by AFL++ fuzzing #11109
2026-03-01 14:30:42 -08:00
Mitchell Hashimoto
dcaa8f3979 terminal: fix out-of-bounds access in CSI W handler with no params
CSI ? W (cursor tabulation control) accessed input.params[0] without
first checking that params.len > 0, causing an index out-of-bounds
panic when the sequence had an intermediate but no parameters.

Add a params.len == 1 guard before accessing params[0].

Found by AFL++ fuzzing.
2026-03-01 14:24:57 -08:00
Mitchell Hashimoto
72df30f14b docs: add clarification for pre-vouching contributors (#11096)
If this PR is accepted, it will add a clarification to the contribution
guidelines to inform pre-vouching contributors that they are still
required to apply for vouching as would a first-time contributor.
2026-03-01 13:27:17 -08:00
ghostty-vouch[bot]
db7c140100 Update VOUCHED list (#11107)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/11102#discussioncomment-15964699)
from @mitchellh.

Vouch: @mischief

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-03-01 21:25:32 +00:00
Mitchell Hashimoto
a48cb630a8 libghostty-vt parser fuzzing, generic fuzz harness, using AFL++ (#11089)
This adds a `test/fuzz-libghostty` which is a standalone `zig build`
target for building an AFL++ instrumented executable for fuzzing the
libghostty-vt parser. I also added a `pkg/afl++` (based on zig-afl-kit)
so instrumenting objects and using AFL++ is a bit easier.

Fuzzing `libghostty-vt`'s parser is as easy as `zig build run`, but see
the README for a lot more details. I ran the fuzzer for ~14 hours total
and only found one crash #11088. I'm pretty confident at this point our
Parser layer isn't obviously crash-able, but need to instrument more
places to fuzz.

We don't use Zig's built-in fuzzing yet because as of 0.15 (our current
stable), it isn't ready and AFL++ is an industry proven tool to do this.
2026-03-01 13:16:52 -08:00
Mitchell Hashimoto
125b6e9f6c Clear key state overlay on "ignore" action (#11103)
This fixes a bug in the key state sequence overlay.

## Demo

In my ghostty config, I have

    keybind = ctrl+space>escape=ignore
    keybind = ctrl+space>p=toggle_command_palette
    ...

because I use `ctrl+space>` sequences for most things and so hitting
`esc` is my way to bail out of the sequence if I change my mind.

I just switched to tip and got the new GTK key sequence overlay. Here's
what I saw. In these screen recordings, the sequence of keys I press is

ctrl+space, escape, ctrl+space, escape, ctrl+space, escape, ctrl+space,
p


https://github.com/user-attachments/assets/4a37bc7e-b75c-4bd1-99de-f21f4211b5b5

after the fix:


https://github.com/user-attachments/assets/023be88e-1299-4219-920c-1b1134b2888c

## Notes

I believe this was also a leak, since the queued keys wouldn't be
deinited.

**AI usage:** Claude Code suggested the fix, then I read enough code to
convince myself that it makes sense.
2026-03-01 13:15:55 -08:00
Alexandre Antonio Juca
c735fd8c47 Update CONTRIBUTING.md
Co-authored-by: Jeffrey C. Ollie <jeff@ocjtech.us>
2026-03-01 22:05:30 +01:00
Alexandre Antonio Juca
3972426852 chore: improve grammer 2026-03-01 21:56:46 +01:00
Alexandre Antonio Juca
fa2a74d765 Update CONTRIBUTING.md
Co-authored-by: Jeffrey C. Ollie <jeff@ocjtech.us>
2026-03-01 21:52:19 +01:00
Alexandre Antonio Juca
56f3b3d060 Update CONTRIBUTING.md
Co-authored-by: Jeffrey C. Ollie <jeff@ocjtech.us>
2026-03-01 21:52:11 +01:00
Alexandre Antonio Juca
059b02eacb Update CONTRIBUTING.md
Co-authored-by: Jeffrey C. Ollie <jeff@ocjtech.us>
2026-03-01 21:51:52 +01:00
Alexandre Antonio Juca
a0b7714898 Update CONTRIBUTING.md
Co-authored-by: Jeffrey C. Ollie <jeff@ocjtech.us>
2026-03-01 21:51:07 +01:00
Mitchell Hashimoto
683de81ee9 typos: ignore fuzz corpus 2026-03-01 09:21:56 -08:00
Mitchell Hashimoto
f43874a168 fuzz: update corpus 2026-03-01 09:20:47 -08:00
Mitchell Hashimoto
7bc44e77d0 shellcheck 2026-03-01 06:54:06 -08:00
Mitchell Hashimoto
41870c14ad ci: test libghostty fuzzer build 2026-03-01 06:53:30 -08:00
Mitchell Hashimoto
e8f861f561 fuzz: replace : with _ for Windows 2026-03-01 06:47:01 -08:00
Mitchell Hashimoto
4f34a0b7d2 ci: fix windows CI checkouts with afl-min filenames 2026-03-01 06:42:58 -08:00
Mitchell Hashimoto
9771aaaebb 🐛 Prevent git log output with signature information (#11094)
When users have something like

[log]
        showSignature = true

in their .gitconfig files, invocations of the log or show git
sub-command emit additional information about signatures. This
additional output disturbs the generation of short_hash in
GitVersion.zig, the additional text is copied verbatim into the string
and then shown in the CSI >q output.

To fix it always suppress the output of the signature information. This
has no effects when the setting is disabled anyway.
2026-03-01 06:39:36 -08:00
ghostty-vouch[bot]
4bef13a4d0 Update VOUCHED list (#11099)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/11090#discussioncomment-15962101)
from @jcollie.

Vouch: @cespare

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-03-01 14:28:35 +00:00
ghostty-vouch[bot]
6cf8f13189 Update VOUCHED list (#11098)
Triggered by
[comment](https://github.com/ghostty-org/ghostty/issues/11094#issuecomment-3980080445)
from @jcollie.

Vouch: @drepper

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-03-01 14:26:26 +00:00
Alexandre Antonio Juca
2ed0e3b82b fix: format with prettier 2026-03-01 12:51:47 +01:00
Alexandre Antonio Juca
fc4d5a40dd chore: add improvements 2026-03-01 12:30:25 +01:00
Alexandre Antonio Juca
7cf8e0ccc0 docs: clarify if pre-vouching contributors are also required to apply to get vouched before contributing to Ghostty 2026-03-01 12:02:20 +01:00
Ulrich Drepper
851b62d738 🐛 Prevent git log output with signature information
When users have something like

[log]
        showSignature = true

in their .gitconfig files, invocations of the log or show git sub-command
emit additional information about signatures.  This additional output
disturbs the generation of short_hash in GitVersion.zig, the additional text
is copied verbatim into the string and then shown in the CSI >q output.

To fix it always suppress the output of the signature information.  This
has no effects when the setting is disabled anyway.
2026-03-01 10:51:48 +01:00
ghostty-vouch[bot]
33c855e047 Update VOUCHED list (#11093)
Triggered by
[comment](https://github.com/ghostty-org/ghostty/issues/5036#issuecomment-3979553300)
from @jcollie.

Vouch: @AlexJuca

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-03-01 09:16:02 +00:00
Caleb Spare
0ccaf3d5d6 Clear key state overlay on "ignore" action 2026-02-28 23:35:28 -08:00
Mitchell Hashimoto
2685efca7a pkg/afl++: remove file arg 2026-02-28 21:14:52 -08:00
Mitchell Hashimoto
346248251e typos 2026-02-28 21:14:52 -08:00
Mitchell Hashimoto
23f6b1af65 pkg/afl++: fuzzer takes a file argument 2026-02-28 21:14:52 -08:00
Mitchell Hashimoto
2bd09523c8 pkg/afl++: use usize for len 2026-02-28 21:14:51 -08:00
Mitchell Hashimoto
eb7d28d180 Corpus management update 2026-02-28 21:14:51 -08:00
Mitchell Hashimoto
1d9f080309 test/fuzz-libghostty: add README 2026-02-28 21:14:51 -08:00
Mitchell Hashimoto
afabbaf012 pkg/afl++: extract runner 2026-02-28 21:14:51 -08:00
Mitchell Hashimoto
54bdbdf87d pkg/afl++: clean up, comments 2026-02-28 21:14:51 -08:00
Mitchell Hashimoto
2a340536a6 test/fuzz-libghostty: add zig build run 2026-02-28 21:14:51 -08:00
Mitchell Hashimoto
673dd474f8 test/fuzz-libghostty: gitignore and initial corpus 2026-02-28 21:14:51 -08:00