diff options
Diffstat (limited to 'shared')
| -rw-r--r-- | shared/nm-utils/nm-shared-utils.c | 44 | ||||
| -rw-r--r-- | shared/nm-utils/nm-shared-utils.h | 3 | ||||
| -rw-r--r-- | shared/nm-version-macros.h | 3 | ||||
| -rw-r--r-- | shared/nm-version-macros.h.in | 1 |
4 files changed, 49 insertions, 2 deletions
diff --git a/shared/nm-utils/nm-shared-utils.c b/shared/nm-utils/nm-shared-utils.c index d0019c11..7a31d68d 100644 --- a/shared/nm-utils/nm-shared-utils.c +++ b/shared/nm-utils/nm-shared-utils.c @@ -497,6 +497,50 @@ _nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gint64 ma return v; } +guint64 +_nm_utils_ascii_str_to_uint64 (const char *str, guint base, guint64 min, guint64 max, guint64 fallback) +{ + guint64 v; + const char *s = NULL; + + if (str) { + while (g_ascii_isspace (str[0])) + str++; + } + if (!str || !str[0]) { + errno = EINVAL; + return fallback; + } + + errno = 0; + v = g_ascii_strtoull (str, (char **) &s, base); + + if (errno != 0) + return fallback; + if (s[0] != '\0') { + while (g_ascii_isspace (s[0])) + s++; + if (s[0] != '\0') { + errno = EINVAL; + return fallback; + } + } + if (v > max || v < min) { + errno = ERANGE; + return fallback; + } + + if ( v != 0 + && str[0] == '-') { + /* I don't know why, but g_ascii_strtoull() accepts minus signs ("-2" gives 18446744073709551614). + * For "-0" that is OK, but otherwise not. */ + errno = ERANGE; + return fallback; + } + + return v; +} + /*****************************************************************************/ /* like nm_strcmp_p(), suitable for g_ptr_array_sort_with_data(). diff --git a/shared/nm-utils/nm-shared-utils.h b/shared/nm-utils/nm-shared-utils.h index d983cfcd..a508f515 100644 --- a/shared/nm-utils/nm-shared-utils.h +++ b/shared/nm-utils/nm-shared-utils.h @@ -245,7 +245,8 @@ gboolean nm_utils_parse_inaddr_prefix (int addr_family, char **out_addr, int *out_prefix); -gint64 _nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gint64 max, gint64 fallback); +gint64 _nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gint64 max, gint64 fallback); +guint64 _nm_utils_ascii_str_to_uint64 (const char *str, guint base, guint64 min, guint64 max, guint64 fallback); gint _nm_utils_ascii_str_to_bool (const char *str, gint default_value); diff --git a/shared/nm-version-macros.h b/shared/nm-version-macros.h index c4b139f8..4eccbde7 100644 --- a/shared/nm-version-macros.h +++ b/shared/nm-version-macros.h @@ -45,7 +45,7 @@ * Evaluates to the micro version number of NetworkManager which this source * compiled against. */ -#define NM_MICRO_VERSION (4) +#define NM_MICRO_VERSION (6) /** * NM_CHECK_VERSION: @@ -75,6 +75,7 @@ #define NM_VERSION_1_12 (NM_ENCODE_VERSION (1, 12, 0)) #define NM_VERSION_1_12_2 (NM_ENCODE_VERSION (1, 12, 2)) #define NM_VERSION_1_12_4 (NM_ENCODE_VERSION (1, 12, 4)) +#define NM_VERSION_1_12_6 (NM_ENCODE_VERSION (1, 12, 6)) /* For releases, NM_API_VERSION is equal to NM_VERSION. * diff --git a/shared/nm-version-macros.h.in b/shared/nm-version-macros.h.in index 792070ac..522652e9 100644 --- a/shared/nm-version-macros.h.in +++ b/shared/nm-version-macros.h.in @@ -75,6 +75,7 @@ #define NM_VERSION_1_12 (NM_ENCODE_VERSION (1, 12, 0)) #define NM_VERSION_1_12_2 (NM_ENCODE_VERSION (1, 12, 2)) #define NM_VERSION_1_12_4 (NM_ENCODE_VERSION (1, 12, 4)) +#define NM_VERSION_1_12_6 (NM_ENCODE_VERSION (1, 12, 6)) /* For releases, NM_API_VERSION is equal to NM_VERSION. * |