[wic][PATCH 3/5] ksparser: reject non-finite overhead factors
Trevor Woerner <[email protected]> Wed, 15 Jul 2026 18:32:24 -0400
| Newsgroups | org.yoctoproject.lists.yocto-patches |
|---|---|
| Message-ID | <[email protected]> |
overheadtype() guards against factors below 1.0, but float("nan") and
float("inf") slip past that check: nan compares false against every
bound, and inf is trivially greater than 1.0. wic then multiplied the
rootfs size by nan or inf (partition.py does
int(rootfs_size * self.overhead_factor)), producing a ValueError deep in
image sizing or a nonsensical partition size.
Reject any non-finite factor up front with math.isfinite() so the error
is reported at parse time alongside the other overhead validation.
AI-Generated: codex/claude-opus 4.8 (xhigh)
Signed-off-by: Trevor Woerner <[email protected]>
---
src/wic/ksparser.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/wic/ksparser.py b/src/wic/ksparser.py
index a73ae56cd196..528a8180826f 100644
--- a/src/wic/ksparser.py
+++ b/src/wic/ksparser.py
@@ -15,6 +15,7 @@
import os
import shlex
import logging
+import math
import re
import uuid
@@ -98,7 +99,7 @@ def overheadtype(arg):
except ValueError:
raise ArgumentTypeError("Invalid value: %r" % arg)
- if result < 1.0:
+ if not math.isfinite(result) or result < 1.0:
raise ArgumentTypeError("Overhead factor should be > 1.0, not %r" % arg)
return result
--
2.50.0.173.g8b6f19ccfc3a