diff options
| author | Zoltán Kéri <z@zolk3ri.name> | 2024-12-24 15:52:33 +0100 |
|---|---|---|
| committer | Zoltán Kéri <z@zolk3ri.name> | 2024-12-24 15:52:33 +0100 |
| commit | f1f2ed31940d02728ce55e591743834968dd5994 (patch) | |
| tree | df259c44d1d9e8fec8782b4ec2961790b06b5544 /src/llvm_backend_expr.cpp | |
| parent | 7672ac945a7b8e35b600a9d2a2421caf16a5a364 (diff) | |
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.
Diffstat (limited to 'src/llvm_backend_expr.cpp')
0 files changed, 0 insertions, 0 deletions