From 396a4dfc2b0d142d186f1a79249123a4e197179d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 1 Apr 2020 13:02:03 +0200 Subject: [PATCH] ifcfg: strip whitespaces around "DEVTIMEOUT" Be more graceful and allow whitespaces around the floating point number for DEVTIMEOUT. Note that _nm_utils_ascii_str_to_int64() is already graceful against whitespace, so also be it with the g_ascii_strtod() code path. (cherry picked from commit 2e4771be5efb2b0e6820243929e55f4bf42c7cad) (cherry picked from commit 5a44792e4127d380a483809959e729d193322221) --- src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index 68ebd78192..82124c1be8 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -543,16 +543,18 @@ make_connection_setting (const char *file, g_object_set (s_con, NM_SETTING_CONNECTION_AUTH_RETRIES, (int) vint64, NULL); nm_clear_g_free (&value); - v = svGetValueStr (ifcfg, "DEVTIMEOUT", &value); + v = svGetValue (ifcfg, "DEVTIMEOUT", &value); if (v) { + v = nm_str_skip_leading_spaces (v); vint64 = _nm_utils_ascii_str_to_int64 (v, 10, 0, ((gint64) G_MAXINT32) / 1000, -1); if (vint64 != -1) vint64 *= 1000; - else { + else if (v[0] != '\0') { char *endptr; double d; d = g_ascii_strtod (v, &endptr); + endptr = nm_str_skip_leading_spaces (endptr); if ( errno == 0 && endptr[0] == '\0' && d >= 0.0) {