Commit Graph

6020 Commits

Author SHA1 Message Date
Laytan
73d1427127 Merge pull request #4662 from IllusionMan1212/jpeg-detection
fix(core/image): off-by-one index when detecting certain JPEG images
2025-01-05 14:23:35 +01:00
gingerBill
acbb14d87e Fix typo 2025-01-05 13:10:29 +00:00
gingerBill
d718db473c Use array with linear search rather than a hash map. 2025-01-05 13:08:01 +00:00
gingerBill
4d63ee0794 Remove unused import 2025-01-05 12:55:35 +00:00
gingerBill
1bf33fe373 Use static global memory for std handles instead of allocating. 2025-01-05 12:53:20 +00:00
Hisham Aburaqibah
247384574a fix(core/image): off-by-one index when detecting certain JPEG images 2025-01-05 13:05:11 +02:00
Jeroen van Rijn
397e371232 Merge pull request #4641 from zolk3ri/fix/base32-error-handling
encoding/base32: Add RFC-compliant error handling and improve reliability
2025-01-04 20:27:16 +01:00
gingerBill
f5e5c9767c Merge pull request #4650 from jasonKercher/arm32-update
Arm32 update for sys/linux
2025-01-04 10:44:44 +00:00
Zoltán Kéri
a4a1562905 encoding/base32: Add @(rodata) attribute to default tables
Add `@(rodata)` attribute to `ENC_TABLE` and `DEC_TABLE` to mark
them as read-only data. This places these tables in the read-only
section of the executable, protecting them from modification
during program execution.
2025-01-03 19:16:56 +01:00
VladPavliuk
1733a50678 Refactor changes. 2025-01-03 18:58:08 +02:00
VladPavliuk
470c05a902 Merge branch 'master' into extend_win32_api_types 2025-01-03 18:53:48 +02:00
VladPavliuk
36b5ca9176 Extend win32 types 2025-01-03 18:52:39 +02:00
jason
1221e393f7 add 32 bit Sig_Info and remove ppoll_time64 call 2025-01-03 09:29:39 -05:00
jason
074bef7baf Fix sys/linux 64 bit arguments on 32 bit systems
Reverese return values of compat64_arg_pair
Add register alignment to specific arm32 system calls
2025-01-02 14:50:45 -05:00
jason
ce1f3b34c0 Minor fixes + cleanup in os2 and sys/linux
Add NOFOLLOW to os2.remove
Change Dev from int to u64 and make relavant casts
Fix compat64_arg_pair
2025-01-02 11:03:24 -05:00
gingerBill
8a5c1b109d Merge pull request #4613 from fnknda/fix-linux-bind
Fix calls to bind always returning EINVAL when using linux.Sock_Addr_In
2025-01-01 17:46:15 +00:00
gingerBill
7248958fcd Merge pull request #4606 from chris-montero/fix_memory_leak_in_core_prof_spall_doc_example
fixed memory leak in core/prof/spall/doc.odin example code
2025-01-01 17:39:20 +00:00
gingerBill
1cf7a56ba7 General clean up of code 2025-01-01 15:13:46 +00:00
Zoltán Kéri
fe88c22b1f encoding/base32: Fix RFC 4648 references and add RFC reference URL
Fix incorrect RFC 4648 section references:
- Add RFC URL reference at package level
- Update Error enum documentation to reference correct sections:
  - Invalid_Character: Section 3.3 (non-alphabet characters)
  - Invalid_Length: Section 6 (base32 block size requirements)
  - Malformed_Input: Section 3.2 (padding)
- Fix test file section references to match correct sections

This ensures all RFC references are accurate and adds a link to the
source RFC for reference.
2024-12-31 23:47:33 +01:00
Zoltán Kéri
d6f4412dc3 encoding/base32: Fix style issues for CI 2024-12-31 18:59:39 +01:00
Laytan
7ffec820ac Merge pull request #4610 from blob1807/master
Fix io.write_escaped_rune not writing full value
2024-12-30 23:53:24 +01:00
Laytan
c02710cce8 Merge pull request #4638 from DataResearch/master
Added proc to user32 Bindings
2024-12-30 23:53:04 +01:00
Laytan
a73c7be8f7 Merge pull request #4600 from jasonKercher/arm64-linux-fixes
Get arm64 up to speed in os2 linux
2024-12-30 23:38:59 +01:00
CodingChris
bddca04b25 added IsZoomed to user32 bindings in sys/windows 2024-12-30 23:20:08 +01:00
Zoltán Kéri
3d25128520 encoding/base32: Convert files to UTF-8 with Unix line endings 2024-12-30 15:31:57 +01:00
Zoltán Kéri
5ce6990077 encoding/base32: Add proper cleanup for encoded strings in tests
Add defer delete for encoded strings across all test procedures to ensure
proper cleanup and prevent memory leaks. This completes the memory
management improvements started in 591dd876.
2024-12-30 15:26:42 +01:00
Zoltán Kéri
8292509769 encoding/base32: Add custom alphabet test case
Add test case to verify custom alphabet support. The test uses a
decimal-uppercase alphabet (0-9, A-V) to test both encoding and decoding
with custom tables, including validation. This ensures the encode and
decode functions work correctly with custom encoding tables and
validation functions as documented.
2024-12-30 15:18:38 +01:00
Zoltán Kéri
591dd8765a encoding/base32: Remove incorrect defer delete in encode()
Remove premature deallocation of the output buffer which was causing
use-after-free behavior. The returned string needs to take ownership
of this memory, but the defer delete was freeing it before the
string could be used. This fixes issues with encoding that were
introduced by overly aggressive memory cleanup in 93238db2.
2024-12-30 12:00:38 +01:00
Zoltán Kéri
0d4c0064d9 encoding/base32: Add encode->decode roundtrip test
Add test_base32_roundtrip() to verify the encode->decode roundtrip
preserves data integrity. This test helps ensure our base32 implementation
correctly handles the full encode->decode cycle without data loss or
corruption.
2024-12-30 03:03:50 +01:00
Zoltán Kéri
c9c59edc64 encoding/base32: Move tests to base32_test.odin
Move existing test procedures to a dedicated test file for better
code organization and maintainability.
2024-12-29 23:35:01 +01:00
Zoltán Kéri
490f527005 encoding/base32: Expand DEC_TABLE to full 256 bytes
The decoding table was only 224 bytes which caused type mismatches when
using custom alphabets, so expand with zeroes to cover full byte range
while maintaining the same decoding logic.
2024-12-26 19:20:46 +01:00
Zoltán Kéri
88c0e62095 encoding/base32: Use ENC_TBL parameter consistently in encode()
Fix encoding to properly use provided encoding table parameter instead of
hardcoded `ENC_TABLE`.

This makes encode properly support custom alphabets as documented.
2024-12-26 14:48:02 +01:00
Zoltán Kéri
e7fb02a84a encoding/base32: Add custom validation support
Add support for custom alphabet validation through an optional validation
function parameter. The default validation follows RFC 4648 base32
alphabet rules (A-Z, 2-7).

This properly supports the documented ability to use custom alphabets.
2024-12-25 16:15:41 +01:00
Zoltán Kéri
8211a911db encoding/base32: Replace padding map with switch statement
Replace package-level map with a simple switch statement for padding
validation. This eliminates allocations we can't properly free while
maintaining the same validation logic.
2024-12-24 20:46:38 +01:00
Zoltán Kéri
e75a49f095 encoding/base32: Set optimization mode for decode() 2024-12-24 16:07:01 +01:00
Zoltán Kéri
93238db202 encoding/base32: Use consistent allocator and add proper cleanup
Fix memory handling throughout base32 package:
- Make padding map package-level constant (to avoid repeated allocs)
- Use passed allocator in encode's make() call
- Add defer delete for allocated memory in encode
- Add proper cleanup in test cases
- Fix memory cleanup of output buffers

The changes ensure consistent allocator usage and cleanup in both
implementation and tests.
2024-12-24 16:00:00 +01:00
Zoltán Kéri
f1f2ed3194 encoding/base32: Fix decode implementation per RFC 4648
Rework base32.decode() to properly handle all cases per RFC 4648:

- Fix error detection order:
  - Check minimum length first (Invalid_Length)
  - Check character validity (Invalid_Character)
  - Check padding and structure (Malformed_Input)

- Fix padding validation:
  - Add required padding length checks (2=6, 4=4, 5=3, 7=1 chars)
  - Ensure padding only appears at end
  - Fix handling of unpadded inputs

- Fix buffer handling:
  - Proper output buffer size calculation
  - Add bounds checking for buffer access
  - Add proper buffer validation

For example:
- "M" correctly returns Invalid_Length (too short)
- "mzxq====" correctly returns Invalid_Character (lowercase)
- "MZXQ=" correctly returns Malformed_Input (wrong padding)
- Unpadded input lengths must be multiples of 8

These changes make the decode function fully compliant with RFC 4648
requirements while providing proper error handling.
2024-12-24 15:52:33 +01:00
Zoltán Kéri
7672ac945a encoding/base32: Add RFC 4648 test suite
Add test suite based on RFC 4648 test vectors and validation rules:
- Add section 10 test vectors for valid encoding/decoding
- Add test cases for invalid character handling (section 3.2)
- Add test cases for padding validation (section 4)
- Add test cases for length requirements (section 6)

The test vectors verify that:
- Empty string encodes/decodes correctly
- Standard cases like "foo" -> "MZXW6===" work
- Invalid characters are rejected
- Missing or malformed padding is detected
- Invalid lengths are caught
2024-12-24 15:28:34 +01:00
Zoltán Kéri
b9338777e3 encoding/base32: Fix buffer allocation and bounds checking
Fix buffer allocation size calculation and add proper bounds checking to
ensure output buffer has sufficient space. This fixes crashes that could
occur with inputs like "AA" and other edge cases where the output buffer
was too small.

Remove #no_bounds_check as proper bounds checking is necessary for safe
error handling. The small performance trade-off is worth the improved
robustness.
2024-12-24 02:20:32 +01:00
Zoltán Kéri
8c761627c8 encoding/base32: Replace assertions with error returns
Replace assertions with proper error handling in base32.decode() to allow
programs to handle invalid input gracefully rather than crashing.

The function now returns ([]byte, Error) instead of just []byte.
2024-12-24 02:17:57 +01:00
Jeroen van Rijn
ad99d20d29 Remove outdated PNG save helpers 2024-12-23 16:33:23 +01:00
Joao Fukuda
28e226381d Remove extra white space
Got in on 0a2200f without me noticing, mb.
2024-12-22 16:09:51 -03:00
Joao Fukuda
0a2200fa12 Fix issue #4612 2024-12-22 15:53:54 -03:00
blob1807
f07a6f463c Fix io.write_escaped_rune not writing full value 2024-12-22 23:10:42 +10:00
chris-montero
c06f79bb36 fixed memory leak in core/prof/spall/doc.odin example code 2024-12-21 15:53:55 +02:00
jason
b73275cf42 Get arm64 up to speed in os2 linux
Readded open flags for arm64 to sys/linux/bits.odin. Make process_start
name based instead of descriptor based to allow running of scripts. Fix
bug in heap_linux. Fix and simplify os2.remove.
2024-12-19 17:12:07 -05:00
gingerBill
61368d942e Merge pull request #4589 from Pariatech/add-trunc-to-linalg-glsl
Add trunc to glsl linalg
2024-12-18 21:20:17 +00:00
Gabriel Pariat
e0b7bfd21e add trunc to glsl linalg 2024-12-17 13:06:59 -05:00
Laytan
8b1c9b0ff5 Merge pull request #4568 from giuliano-macedo/master
docs: improved `slice.reinterpret` docstring
2024-12-14 16:46:17 +01:00
Giuliano Macedo
6785a485e3 docs: improved reinterpret docstring 2024-12-14 10:10:06 -03:00