mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 00:50:16 +01:00
ifcfg-rh: don't use get_int() to parse MTU value
And print a warning also if the value is out of range.
This commit is contained in:
parent
ec639b5c63
commit
7328613d7b
1 changed files with 12 additions and 14 deletions
|
|
@ -3773,20 +3773,19 @@ make_wired_setting (shvarFile *ifcfg,
|
|||
{
|
||||
NMSettingWired *s_wired;
|
||||
char *value = NULL;
|
||||
int mtu;
|
||||
char *nettype;
|
||||
|
||||
s_wired = NM_SETTING_WIRED (nm_setting_wired_new ());
|
||||
|
||||
value = svGetValue (ifcfg, "MTU", FALSE);
|
||||
if (value) {
|
||||
if (get_int (value, &mtu)) {
|
||||
if (mtu >= 0 && mtu < 65536)
|
||||
g_object_set (s_wired, NM_SETTING_WIRED_MTU, (guint) mtu, NULL);
|
||||
} else {
|
||||
/* Shouldn't be fatal... */
|
||||
int mtu;
|
||||
|
||||
mtu = _nm_utils_ascii_str_to_int64 (value, 0, 0, 65535, -1);
|
||||
if (mtu >= 0)
|
||||
g_object_set (s_wired, NM_SETTING_WIRED_MTU, (guint) mtu, NULL);
|
||||
else
|
||||
PARSE_WARNING ("invalid MTU '%s'", value);
|
||||
}
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
|
|
@ -4024,19 +4023,18 @@ make_infiniband_setting (shvarFile *ifcfg,
|
|||
{
|
||||
NMSettingInfiniband *s_infiniband;
|
||||
char *value = NULL;
|
||||
int mtu;
|
||||
|
||||
s_infiniband = NM_SETTING_INFINIBAND (nm_setting_infiniband_new ());
|
||||
|
||||
value = svGetValue (ifcfg, "MTU", FALSE);
|
||||
if (value) {
|
||||
if (get_int (value, &mtu)) {
|
||||
if (mtu >= 0 && mtu < 65536)
|
||||
g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MTU, (guint) mtu, NULL);
|
||||
} else {
|
||||
/* Shouldn't be fatal... */
|
||||
int mtu;
|
||||
|
||||
mtu = _nm_utils_ascii_str_to_int64 (value, 0, 0, 65535, -1);
|
||||
if (mtu >= 0)
|
||||
g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MTU, (guint) mtu, NULL);
|
||||
else
|
||||
PARSE_WARNING ("invalid MTU '%s'", value);
|
||||
}
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue