about summary refs log tree commit diff
path: root/shared/nm-utils/nm-shared-utils.c
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2018-12-10 18:50:07 +0100
committerSebastien Bacher <seb128@ubuntu.com>2018-12-10 21:58:19 +0100
commite335b8ae803a5a0f28a692edc0349ababa490445 (patch)
tree753f3d62d0aaa2ab6a831f8dcfa525d714868d0c /shared/nm-utils/nm-shared-utils.c
parent69385b013384918a005052098d5beae003b4c8d3 (diff)
parent227c401a10a930af6fd5f123aef345fcd130d6aa (diff)
Import Debian changes 1.12.6-0ubuntu1
network-manager (1.12.6-0ubuntu1) disco; urgency=medium

  * New upstream version
    - Fix a vulnerability in the internal DHCPv6 client (CVE-2018-15688).
  * debian/patches/git_mac_change.patch:
    - backported a regression fix from upstream git

  [ Alfonso Sanchez-Beato ]
  * Import some WoWLAN patches from the newer stable serie (LP: #1781597)
Diffstat (limited to 'shared/nm-utils/nm-shared-utils.c')
-rw-r--r--shared/nm-utils/nm-shared-utils.c44
1 files changed, 44 insertions, 0 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().