diff --git a/clients/tui/newt/nmt-newt-entry-numeric.c b/clients/tui/newt/nmt-newt-entry-numeric.c index a52fe8689f..92855fcb2c 100644 --- a/clients/tui/newt/nmt-newt-entry-numeric.c +++ b/clients/tui/newt/nmt-newt-entry-numeric.c @@ -127,8 +127,8 @@ newt_entry_numeric_validate (NmtNewtEntry *entry, if (!*text) return priv->optional ? TRUE : FALSE; - val = _nm_utils_ascii_str_to_int64 (text, 10, priv->min, priv->max, 0); - return val != 0 || errno == 0; + val = _nm_utils_ascii_str_to_int64 (text, 10, priv->min, priv->max, G_MAXINT64); + return val != G_MAXINT64 || errno == 0; } static void diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c index b36ed20851..51ce2debbc 100644 --- a/libnm-core/nm-setting-bond.c +++ b/libnm-core/nm-setting-bond.c @@ -175,19 +175,14 @@ nm_setting_bond_get_option (NMSettingBond *setting, static gboolean validate_int (const char *name, const char *value, const BondDefault *def) { - long num; - guint i; + guint64 num; - for (i = 0; i < strlen (value); i++) { - if (!g_ascii_isdigit (value[i]) && value[i] != '-') - return FALSE; - } - - errno = 0; - num = strtol (value, NULL, 10); - if (errno) + if (!NM_STRCHAR_ALL (value, ch, g_ascii_isdigit (ch))) return FALSE; - if (num < def->min || num > def->max) + + num = _nm_utils_ascii_str_to_uint64 (value, 10, def->min, def->max, G_MAXUINT64); + if ( num == G_MAXUINT64 + && errno != 0) return FALSE; return TRUE; diff --git a/src/supplicant/nm-supplicant-settings-verify.c b/src/supplicant/nm-supplicant-settings-verify.c index 2ed918b602..f10bbb0431 100644 --- a/src/supplicant/nm-supplicant-settings-verify.c +++ b/src/supplicant/nm-supplicant-settings-verify.c @@ -157,23 +157,13 @@ validate_type_int (const struct Opt * opt, const char * value, const guint32 len) { - long int intval; + gint64 v; g_return_val_if_fail (opt != NULL, FALSE); g_return_val_if_fail (value != NULL, FALSE); - errno = 0; - intval = strtol (value, NULL, 10); - if (errno != 0) - return FALSE; - - /* strtol returns a long, but we are dealing with ints */ - if (intval > INT_MAX || intval < INT_MIN) - return FALSE; - if (intval > opt->int_high || intval < opt->int_low) - return FALSE; - - return TRUE; + v = _nm_utils_ascii_str_to_int64 (value, 10, opt->int_low, opt->int_high, G_MININT64); + return v != G_MININT64 || errno == 0; } static gboolean