Commit Graph
790 Commits
Author SHA1 Message Date
Ihor Antonov 0aee554caa core/crypto/_fiat/field_p256r1: fix fe_sqrt addition chain base
Step 4 (t0 = x^0xc) passed x^1 (&xx) instead of x^3 (out1), producing
an incorrect exponent and rejecting valid quadratic residues. This broke
compressed SEC1 P-256 point decoding via pt_set_sec_bytes.
2026-09-25 13:49:23 -07:00
Jeroen van Rijn 413a634cef Merge pull request #7633 from JackMordaunt/json-unquote-invalid-utf8
core/encoding/json: size the unquote buffer for replaced invalid UTF-8
2026-09-25 11:22:40 -07:00
Jack Mordaunt 641844dae7 core/encoding/json: size the unquote buffer for replaced invalid UTF-8
unquote_string replaces each byte that is not valid UTF-8 with U+FFFD,
which is three bytes for one, but sized its buffer as len(s) + 2*UTF_MAX:
slack for a single replacement, not for one per invalid byte. A string
holding several ran the write cursor past the end, an out-of-range slice
under bounds checking and a memory-safety bug without it.

Count the invalid bytes in the remainder up front and size for them. The
escape sequences never grow their input, so they need no allowance.
2026-09-25 14:27:40 -03:00
Louis Novy 45b8f63960 rat_mul_rat: fix squaring path writing the denominator into the numerator 2026-09-24 09:11:20 -04:00
Matthias Huerbe 50ca03440d added a hexadecimal floating-point parsing test 2026-09-24 10:08:44 +00:00
Tom Gautot e43040d371 Add core/odin parsing test checking both triple quote and triple tick strings 2026-09-10 21:55:28 +02:00
BlackHole00 0672a7c683 Implement tests for the mem.Scratch allocator
Checks that the backing memory of the scratch
allocator gets reused upon memory depletion.
Checks that the backing allocator only gets used
when allocations bigger than the backing memory are
requested.
2026-09-05 00:42:38 +02:00
user.name 6ccde7f80b bugfix: core/encoding/json leaks the key and value of a malformed object
parse_object_body allocates an object key, then may fail in parse_colon or
parse_value before that key is ever inserted into the object. Its cleanup defer
only walks `obj`, so a key that never got there is unreachable to it. The caller
cannot free it either -- a failed parse returns a nil Value -- so it leaks.

The same applies to the parsed element on the duplicate-key path, and to both on
the out-of-memory path.

JSON5 makes this reachable from ordinary malformed input, because an unquoted
ident is a legal key and anything other than a colon after it fails. Plain JSON
leaks it too, via a quoted key.

before, measured with a tracking allocator over 8 inputs x 2 specs:

	LEAK JSON5  colon fails after unquoted key   1 alloc / 7 bytes
	LEAK JSON   colon fails after quoted key     1 alloc / 2 bytes
	LEAK JSON5  colon fails after quoted key     1 alloc / 2 bytes
	LEAK JSON   value fails after key            1 alloc / 2 bytes
	LEAK JSON5  value fails after key            1 alloc / 2 bytes
	LEAK JSON   nested value fails               2 alloc / 4 bytes
	LEAK JSON5  nested value fails               2 alloc / 4 bytes
	LEAK JSON   deep nesting fails               3 alloc / 6 bytes
	LEAK JSON5  deep nesting fails               3 alloc / 6 bytes
	LEAK JSON   array element fails              1 alloc / 2 bytes
	LEAK JSON5  array element fails              1 alloc / 2 bytes
	total leaked allocations: 17

after, same probe:

	total leaked allocations: 0

The leak scales with nesting depth -- one orphaned key per enclosing object -- so
a service parsing untrusted JSON leaks a little on every malformed request.

The fix marks the key and the element as owned by the loop iteration until they
are stored, and frees them otherwise. The duplicate-key path loses its explicit
delete, which the same mechanism now covers.

Found via odinfmt, which reported a 7-byte leak in a downstream test that parses
`{ broken not json` to check that invalid input is rejected.

Regression test added to tests/core/encoding/json: it reports
`17 leaks and 0 bad frees` without this change and passes with it. The existing
11 tests pass unchanged under -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true.
2026-08-31 11:39:42 -07:00
thetarnav db2f88cff9 Improve parsing field docs and comments (fixes #5353) 2026-08-29 19:22:18 +02:00
Jeroen van Rijn 9909676141 Merge pull request #7462 from MoonlightChase/fix-grapheme-width
This Fixes #5939 , where many characters like flags are reported with…
2026-08-26 06:14:30 -07:00
MoonlightChase 556bdb0056 This Fixes #5939 , where many characters like flags are reported with width 1 even though their width is 2. Country glags need additional special case also since RI letters are EAW neutral and not Wide.
i was working on this when i stumbled on this bug, so i did bunch of different characters to see which ones cause issue, hence test has many different options. I could make it either simpler or split it, as needed.
2026-08-26 13:31:43 +02:00
Jeroen van Rijn 6a83f08c8b Fix justified printing of 0 producing all spaces. 2026-08-26 12:11:38 +02:00
kalsprite 7d7d9a01ee fill left-justified field with spaces 2026-08-25 23:55:55 -07:00
Jeroen van Rijn 33d4c68abe Merge pull request #7401 from kalsprite/nbio_windows_wakeup
nbio(windows): fix use-after-free, spurious poll readiness, and double completion
2026-08-24 19:02:24 -07:00
Jeroen van Rijn 24d86de624 One more. 2026-08-23 21:49:39 +02:00
Jeroen van Rijn 2439aaf181 Remove imports of deprecated core:os/old. 2026-08-23 21:46:30 +02:00
Manuel d79ef965a0 Fix formatting 2026-08-22 21:50:07 +02:00
Manuel ee04c3b272 Add murmur3 implementation 2026-08-22 15:48:38 +02:00
kalsprite fe52f23b50 tests/core/nbio/remove.odin 2026-08-21 15:25:18 -07:00
kalsprite d29b2cadbd nbio(tests): fill the socket until sending blocks 2026-08-21 21:58:40 -07:00
kalsprite 7bb55ba45b nbio(windows): poll sockets through AFD 2026-08-21 21:31:49 -07:00
kalsprite 1b4e14fbc5 restore fail timeout 2026-08-21 20:43:33 -07:00
kalsprite d2da33235d nbio(windows): handle queued work in the tick that was woken for it; nbio(tests): let wake_up tolerate a tick that returns without progress 2026-08-21 09:18:57 -07:00
Karl Zylinski a0a75bf4a7 Split the non-specific parts of the Handle Map out to a general.odin file. This means that the Handles and the generic procedure groups are no longer in static_handle_map.odin. Also enabled and fixed the static handle map test. Added another test that uses the generic procedure groups. 2026-08-19 17:03:59 +02:00
Samuel Elgozi 4a08f5c48a mem: Preserve alignment when reusing Dynamic_Arena blocks 2026-08-17 00:21:50 +03:00
Jeroen van Rijn cc7d6764d3 Merge pull request #7349 from TheRadischen/merge_sort
improved stable sort | from insertion_sort to merge_rotate
2026-08-16 16:03:57 +02:00
TheRadischen f6b8eafdfd imporved_style 2026-08-16 15:10:01 +02:00
TheRadischen 9757fed9f9 changed_to_tabs 2026-08-16 14:28:38 +02:00
TheRadischen 3f851d2b02 smarter_test 2026-08-16 12:27:30 +02:00
TheRadischen df54692a9b addedtest 2026-08-16 12:22:25 +02:00
mo 4e0a71c24c Add non-allocating hex.decode_into_buffer
Also minor fixes to documentation of hex.decode().

Adds tests of the new procedure with buffers the correct size, larger,
and too small.
2026-08-16 19:48:19 +12:00
Jeroen van Rijn 44b2f201f5 Remove log 2026-08-12 14:09:07 +02:00
Jeroen van Rijn e5bf7ba6e3 Skip some tests on riscv 2026-08-12 13:59:51 +02:00
Mihail Moskov 9e73c20197 adds the pop procedure family for soa arrays 2026-08-11 15:21:23 +03:00
corley 87912a8b88 fixes range loop over array elements in soa containers 2026-08-11 03:20:13 +03:00
Karl ZylinskiandClaude Opus 5 1f9b4c4555 Add text field to utf8.Grapheme, fix caret translation by grapheme
`decode_grapheme_iterate` already computed the text of each grapheme
cluster, but `decode_grapheme_clusters` discarded it, forcing callers to
reconstruct each cluster's range by looking ahead to the next grapheme's
`byte_index`. Store it on `Grapheme` instead; it is a slice of the input
string, so no allocation is involved.

`core:text/edit` was using `Grapheme.width` -- the number of monospace
cells -- as a byte count when moving the caret by grapheme, so it landed
in the middle of a cluster for anything wider than one byte per cell. Use
`len(Grapheme.text)`, and add a test package for the translations.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 12:27:31 +02:00
corley e374541599 fixes chained indexing for soa containers with array element type 2026-08-09 22:23:32 +03:00
corley 7b45adf8e9 fixes swizzling for array elements in soa arrays/slices 2026-08-09 03:17:04 +03:00
jack gleeson 2162e7605e core/unicode/utf8: Fix truncated text for grapheme clusters 2026-08-07 10:36:14 -06:00
Jeroen van Rijn 1daec0865c Merge pull request #7234 from michtesar/fix/net-percent-encode
Fix percent encoding for bytes < 0x10
2026-08-06 13:54:36 +02:00
Michael Tesař a1cb87c1c4 Add decode roundtrip test 2026-08-06 07:14:50 +02:00
Michael Tesař 56d8293ae0 Restore formatting and remove unused import 2026-08-05 23:58:33 +02:00
Michael Tesař f7f95ad763 Add percent_encode_test to test percent 2026-08-05 23:40:57 +02:00
Jeroen van Rijn ddf60b459d #+build !netbsd 2026-08-05 12:28:39 +02:00
Jeroen van Rijn fd3d182ee5 Assuage NetBSD CI 2026-08-05 12:12:08 +02:00
gingerBill 6c2bb94ceb Merge pull request #7206 from ssenthilnathan3/fix/os-glob-clone
Fix os.glob not cloning pattern when no meta characters present
2026-08-04 10:52:43 +02:00
Senthilnathan b838b1bf25 fixes os.glob not cloning pattern when no meta characters present 2026-08-04 12:19:03 +05:30
corley 439edc5fa8 make soa builtins go vroom 2026-08-03 02:32:09 +03:00
Jeroen van Rijn 280f02f4ef Remove unused import 2026-08-02 15:08:08 +02:00
Jeroen van Rijn 447d880586 Add tests/core/text/scanner to CI 2026-08-02 13:19:15 +02:00