From: Yu Watanabe Date: Mon, 25 Feb 2019 03:35:40 +0000 (+0900) Subject: udev/ethtool: fix error detection of ethtool_link_mode_bit_from_string() X-Git-Tag: v242-rc1~252^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=84fb56d396b14fb778dbe51f02d247f0899a74ef;p=thirdparty%2Fsystemd.git udev/ethtool: fix error detection of ethtool_link_mode_bit_from_string() --- diff --git a/src/udev/net/ethtool-util.c b/src/udev/net/ethtool-util.c index 6a0a42386be..55620926dc4 100644 --- a/src/udev/net/ethtool-util.c +++ b/src/udev/net/ethtool-util.c @@ -775,7 +775,9 @@ int config_parse_advertise(const char *unit, break; mode = ethtool_link_mode_bit_from_string(w); - if (mode < 0) { + /* We reuse the kernel provided enum which does not contain negative value. So, the cast + * below is mandatory. Otherwise, the check below always passes and access an invalid address. */ + if ((int) mode < 0) { log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse advertise mode, ignoring: %s", w); continue; }