]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
parse-util: refuse leading white space in port number
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 1 Dec 2021 23:31:55 +0000 (08:31 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 1 Dec 2021 23:36:22 +0000 (08:36 +0900)
When parse_ip_port() is directly used in a conf parser, then that's
fine, as the rvalue is already truncated.

When parse_ip_port() is used when e.g. parsing IP address with port,
then we should really refuse white space after colon.

src/basic/parse-util.c

index d03a6eeb05e593062abfa083b5f7bcfbe11f7fdc..2888ab6523f59e3395714d18b48de706341f38e4 100644 (file)
@@ -644,7 +644,7 @@ int parse_ip_port(const char *s, uint16_t *ret) {
         uint16_t l;
         int r;
 
-        r = safe_atou16(s, &l);
+        r = safe_atou16_full(s, SAFE_ATO_REFUSE_LEADING_WHITESPACE, &l);
         if (r < 0)
                 return r;