network: fix ListenPort= in [WireGuard] section
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 24 Apr 2019 22:39:04 +0000 (00:39 +0200)
committerMichael Biebl <biebl@debian.org>
Wed, 4 Sep 2019 17:34:17 +0000 (18:34 +0100)
This fixes a bug introduced by f1368a333e5e08575f0b45dfe41e936b106a8627.

Fixes #12377.

(cherry picked from commit a62b7bb79e9a2aa683624c32cde1c756d8466fb4)

Gbp-Pq: Name network-fix-ListenPort-in-WireGuard-section.patch

src/network/netdev/wireguard.c

index 7959c1c01f45f5ca0eeaac50fad6e33b36ae2643..6babb7950ac055ac59f4526c1c3836b70e8e952c 100644 (file)
@@ -453,22 +453,23 @@ int config_parse_wireguard_listen_port(
                 void *userdata) {
 
         uint16_t *s = data;
-        uint16_t port = 0;
         int r;
 
         assert(rvalue);
         assert(data);
 
-        if (!streq(rvalue, "auto")) {
-                r = parse_ip_port(rvalue, s);
-                if (r < 0) {
-                        log_syntax(unit, LOG_ERR, filename, line, r,
-                                   "Invalid port specification, ignoring assignment: %s", rvalue);
-                        return 0;
-                }
+        if (isempty(rvalue) || streq(rvalue, "auto")) {
+                *s = 0;
+                return 0;
+        }
+
+        r = parse_ip_port(rvalue, s);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, r,
+                           "Invalid port specification, ignoring assignment: %s", rvalue);
+                return 0;
         }
 
-        *s = port;
         return 0;
 }