diff options
| author | David Gibson <david@gibson.dropbear.id.au> | 2026-03-27 15:34:24 +1100 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-03-28 14:35:56 +0100 |
| commit | 9c37a481f12a5fbbeb98dbc16763e444f0322f57 (patch) | |
| tree | 5c7a30ee0e1efa850a17e723229d045ec864865e | |
| parent | 66e26b95e4886f35301829c3ed2af458796b312f (diff) | |
| download | passt-9c37a481f12a5fbbeb98dbc16763e444f0322f57.tar passt-9c37a481f12a5fbbeb98dbc16763e444f0322f57.tar.gz passt-9c37a481f12a5fbbeb98dbc16763e444f0322f57.tar.bz2 passt-9c37a481f12a5fbbeb98dbc16763e444f0322f57.tar.lz passt-9c37a481f12a5fbbeb98dbc16763e444f0322f57.tar.xz passt-9c37a481f12a5fbbeb98dbc16763e444f0322f57.tar.zst passt-9c37a481f12a5fbbeb98dbc16763e444f0322f57.zip | |
conf: Move check for mapping port 0 to caller
conf_ports_range_except() checks that it hasn't been asked to map port 0,
which generally won't work. However, there's only one callsite that
doesn't statically pass a non-zero value here. Change the check to an
assert() and move the actual error message to that callsite. This will
allow further cleanups later.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | conf.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -151,10 +151,7 @@ static void conf_ports_range_except(const struct ctx *c, char optname, unsigned base, i; uint8_t proto; - if (first == 0) { - die("Can't forward port 0 for option '-%c %s'", - optname, optarg); - } + assert(first != 0); if (optname == 't' || optname == 'T') proto = IPPROTO_TCP; @@ -404,6 +401,11 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg, if ((*p != '\0') && (*p != ',')) /* Garbage after the ranges */ goto bad; + if (orig_range.first == 0) { + die("Can't forward port 0 for option '-%c %s'", + optname, optarg); + } + conf_ports_range_except(c, optname, optarg, fwd, addr, ifname, orig_range.first, orig_range.last, |
