From: Yu Watanabe Date: Tue, 31 Jul 2018 16:15:23 +0000 (+0900) Subject: network: make compare functions safe X-Git-Tag: v240~870^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ca52812a942841b26e41a58a8f2248cd65e62128;p=thirdparty%2Fsystemd.git network: make compare functions safe As the variable 'line' is unsigned. --- diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 429aac5e6c8..1f1cdced8f1 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -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 = {