fix(info): handle missing deps field without unsigned indexOf wrap
This commit is contained in:
@@ -42,3 +42,27 @@ step 13: cleanup... [32mPASS[0m
|
||||
=== smoketest complete ===
|
||||
PASS: 16 checks passed
|
||||
All checks passed.
|
||||
|
||||
=== FIX (task 27): info.d unsigned indexOf wrap ===
|
||||
Bug: src/tofu/commands/info.d:93 — `size_t pos = content.indexOf("deps")`.
|
||||
indexOf returns ptrdiff_t (-1 for not found); unsigned size_t wraps -1 to
|
||||
SIZE_MAX, making `if (pos < 0)` a no-op → ArrayIndexError on recipes
|
||||
without a deps field (uncaught D Error, crashed -Si).
|
||||
|
||||
Fix applied:
|
||||
1. scanDepsArray: size_t pos → ptrdiff_t pos (+ explanatory comment).
|
||||
2. Added regression unittest (Test 4): cached recipe WITHOUT deps field
|
||||
(name/ver/summary/build_system only) → infoCommand returns 0.
|
||||
Recipe written via existing writeRecipe helper, mirrors Test 3 pattern.
|
||||
|
||||
Audit of same pattern elsewhere (checked, NOT bugs):
|
||||
- info.d:36 auto kp = ...indexOf(key) → auto infers ptrdiff_t ✓
|
||||
- recipeparse.d:52,112 auto idx = indexOf(...) → ptrdiff_t ✓
|
||||
- fetch.d:82 auto idx = indexOf(...) → ptrdiff_t ✓
|
||||
- search.d / remove.d / install.d → inline >= 0 / == -1 ✓
|
||||
No other unsigned indexOf assignment found.
|
||||
|
||||
Verification:
|
||||
dub build → Linking tofu (pass)
|
||||
dub test → 23 modules passed unittests
|
||||
smoketest → PASS: 16 checks passed, All checks passed.
|
||||
|
||||
Reference in New Issue
Block a user