]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: do not reallocate buffer
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 28 Aug 2020 03:53:08 +0000 (12:53 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 3 Sep 2020 23:48:04 +0000 (08:48 +0900)
src/network/networkd-routing-policy-rule.c

index 4befc2f498201e42c62f304ab41f943b439268d3..e7e89db97e983ff98ecb30417417eb4f1878f84f 100644 (file)
@@ -1340,17 +1340,21 @@ int routing_policy_load_rules(const char *state_file, Set **rules) {
                         return r;
 
                 for (;;) {
-                        _cleanup_free_ char *word = NULL, *a = NULL, *b = NULL;
+                        _cleanup_free_ char *a = NULL;
+                        char *b;
 
-                        r = extract_first_word(&p, &word, NULL, 0);
+                        r = extract_first_word(&p, &a, NULL, 0);
                         if (r < 0)
                                 return r;
                         if (r == 0)
                                 break;
 
-                        r = split_pair(word, "=", &a, &b);
-                        if (r < 0)
+                        b = strchr(a, '=');
+                        if (!b) {
+                                log_warning_errno(r, "Failed to parse RPDB rule, ignoring: %s", a);
                                 continue;
+                        }
+                        *b++ = '\0';
 
                         if (STR_IN_SET(a, "from", "to")) {
                                 union in_addr_union *buffer;