diff options
| author | David Gibson <david@gibson.dropbear.id.au> | 2026-04-10 11:03:00 +1000 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-04-15 23:32:00 +0200 |
| commit | ea5a4bb0f2c6a869919e5105b98a45c62cfd70e6 (patch) | |
| tree | eddd9261fc3e5f617c71fc190e18ed4bfbb48505 | |
| parent | 42c49e8c3bc4f8dc8cf63511201675ba6da7c1e8 (diff) | |
| download | passt-ea5a4bb0f2c6a869919e5105b98a45c62cfd70e6.tar passt-ea5a4bb0f2c6a869919e5105b98a45c62cfd70e6.tar.gz passt-ea5a4bb0f2c6a869919e5105b98a45c62cfd70e6.tar.bz2 passt-ea5a4bb0f2c6a869919e5105b98a45c62cfd70e6.tar.lz passt-ea5a4bb0f2c6a869919e5105b98a45c62cfd70e6.tar.xz passt-ea5a4bb0f2c6a869919e5105b98a45c62cfd70e6.tar.zst passt-ea5a4bb0f2c6a869919e5105b98a45c62cfd70e6.zip | |
After parsing port ranges conf_ports_spec() checks if we've reached a
chunk delimiter (',') to verify that there isn't extra garbage there.
Rework how we do this to use the recently introduced chunk-end
pointer. This has two advantages:
1) Small, but practical: we don't need to repeat what the valid delimiters
are, that's already handled in the chunk splitting code.
2) Large, if theoretical: this will also give an error if port parsing
overruns a chunk boundary. We don't really expect that to happen,
but it would be very confusing if it did. strtoul(3), on which
parse_port_range() is based does say it may accept thousands
separators based on locale which means we can't be sure it will
only accept strings of digits.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | conf.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -264,7 +264,7 @@ static void conf_ports_spec(const struct ctx *c, if (parse_port_range(p, &p, &xrange)) goto bad; - if ((*p != '\0') && (*p != ',')) /* Garbage after the range */ + if (p != ep) /* Garbage after the range */ goto bad; for (i = xrange.first; i <= xrange.last; i++) @@ -303,7 +303,7 @@ static void conf_ports_spec(const struct ctx *c, mapped_range = orig_range; } - if ((*p != '\0') && (*p != ',')) /* Garbage after the ranges */ + if (p != ep) /* Garbage after the ranges */ goto bad; if (orig_range.first == 0) { |
