From ca52812a942841b26e41a58a8f2248cd65e62128 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 1 Aug 2018 01:15:23 +0900 Subject: [PATCH] network: make compare functions safe As the variable 'line' is unsigned. --- src/network/networkd-network.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 = { -- 2.39.2