diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2018-10-22 08:26:45 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2018-10-22 15:27:35 +0200 |
commit | e45f53c4e0da69b9f8c014694e555c935cb5b8b2 (patch) | |
tree | 97adaa761055a6f1e0e9695faf9dd087cda5bfd4 | |
parent | 5eade4da11ee38a0e7faf4a87b2c2b5af07c5eeb (diff) | |
download | NetworkManager-bg/issue66.tar.gz |
initrd: cmdline-reader: fix setting uint propertiesbg/issue66
Previously a uint property was assigned with a guint64 value, which
has a different size. Fix this and add a warning when the read value
can't be converted.
Fixes: ecc074b2f8a6240d50f590c898b33158806b51a1
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/66
-rw-r--r-- | src/initrd/nmi-cmdline-reader.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/initrd/nmi-cmdline-reader.c b/src/initrd/nmi-cmdline-reader.c index fa83a9edd5..c4376a3ce4 100644 --- a/src/initrd/nmi-cmdline-reader.c +++ b/src/initrd/nmi-cmdline-reader.c @@ -138,9 +138,17 @@ _base_setting_set (NMConnection *connection, const char *property, const char *v setting = nm_connection_get_setting_by_name (connection, type_name); - if (G_IS_PARAM_SPEC_UINT (spec)) - g_object_set (setting, property, g_ascii_strtoull (value, NULL, 10), NULL); - else if (G_IS_PARAM_SPEC_STRING (spec)) + if (G_IS_PARAM_SPEC_UINT (spec)) { + guint v; + + v = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT, 0); + if ( errno + || !nm_g_object_set_property_uint (setting, property, v, NULL)) { + _LOGW (LOGD_CORE, + "Could not set property '%s.%s' to '%s'", + type_name, property, value); + } + } else if (G_IS_PARAM_SPEC_STRING (spec)) g_object_set (setting, property, value, NULL); else _LOGW (LOGD_CORE, "Don't know how to set '%s' of %s", property, type_name); |