From: Trevor Woerner <twoerner@gmail.com>
To: yocto-patches@lists.yoctoproject.org
Subject: [wic][PATCH 3/5] ksparser: reject non-finite overhead factors
Date: Wed, 15 Jul 2026 18:32:24 -0400 [thread overview]
Message-ID: <20260715223226.3371498-4-twoerner@gmail.com> (raw)
In-Reply-To: <20260715223226.3371498-1-twoerner@gmail.com>
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 <twoerner@gmail.com>
---
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
next prev parent reply other threads:[~2026-07-15 22:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 22:32 [wic][PATCH 0/5] ksparser: four argparse-type fixes plus unit coverage Trevor Woerner
2026-07-15 22:32 ` [wic][PATCH 1/5] ksparser: reject negative sizes in sizetype() Trevor Woerner
2026-07-15 22:32 ` [wic][PATCH 2/5] ksparser: fix crash on out-of-range overhead factor Trevor Woerner
2026-07-15 22:32 ` Trevor Woerner [this message]
2026-07-15 22:32 ` [wic][PATCH 4/5] ksparser: require an explicit 0x prefix for --system-id Trevor Woerner
2026-07-15 22:32 ` [wic][PATCH 5/5] tests/unit/test_ksparser_types: cover ksparser's argparse types Trevor Woerner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260715223226.3371498-4-twoerner@gmail.com \
--to=twoerner@gmail.com \
--cc=yocto-patches@lists.yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.