ifcfg-rh: limit reading GATEWAY_PING_TIMEOUT to 600 seconds

libnm-core limits the rande for GATEWAY_PING_TIMEOUT to 0 to 600.
See commit e86f8354a7, "device: restart
ping process when it exits with an error".

The reader must not pass value out of range to g_object_set().
Clamp and warn.
This commit is contained in:
Thomas Haller 2017-10-18 17:53:59 +02:00
parent ab1e672a21
commit d1a58fbfbf

View file

@ -249,9 +249,13 @@ make_connection_setting (const char *file,
gint64 tmp;
tmp = _nm_utils_ascii_str_to_int64 (v, 10, 0, G_MAXINT32 - 1, -1);
if (tmp >= 0)
if (tmp >= 0) {
if (tmp > 600) {
tmp = 600;
PARSE_WARNING ("invalid GATEWAY_PING_TIMEOUT time");
}
g_object_set (s_con, NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT, (guint) tmp, NULL);
else
} else
PARSE_WARNING ("invalid GATEWAY_PING_TIMEOUT time");
}