]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: make compare functions safe
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 31 Jul 2018 16:15:23 +0000 (01:15 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 2 Aug 2018 08:06:03 +0000 (17:06 +0900)
As the variable 'line' is unsigned.

src/network/networkd-network.c

index 429aac5e6c87c2256d657f9f6777841d14a2a778..1f1cdced8f12e76810edf9abf853c4a27db1c5f0 100644 (file)
@@ -36,7 +36,12 @@ static int network_config_compare_func(const void *a, const void *b) {
         if (r != 0)
                 return r;
 
-        return y->line - x->line;
+        if (x->line < y->line)
+                return -1;
+        if (x->line > y->line)
+                return 1;
+
+        return 0;
 }
 
 const struct hash_ops network_config_hash_ops = {