Browse Source

Parse config_version as 64-bit uint

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Jan Friesse 13 years ago
parent
commit
6825c1d39b
1 changed files with 31 additions and 0 deletions
  1. 31 0
      exec/coroparse.c

+ 31 - 0
exec/coroparse.c

@@ -357,6 +357,29 @@ static int safe_atoi(const char *str, int *res)
 	return (0);
 }
 
+static int str_to_ull(const char *str, unsigned long long int *res)
+{
+	unsigned long long int val;
+	char *endptr;
+
+	errno = 0;
+
+	val = strtoull(str, &endptr, 10);
+	if (errno == ERANGE) {
+		return (-1);
+	}
+
+	if (endptr == str) {
+		return (-1);
+	}
+
+	if (*endptr != '\0') {
+		return (-1);
+	}
+
+	*res = val;
+	return (0);
+}
 
 static int main_config_parser_cb(const char *path,
 			char *key,
@@ -366,6 +389,7 @@ static int main_config_parser_cb(const char *path,
 			void *user_data)
 {
 	int i;
+	unsigned long long int ull;
 	int add_as_string;
 	char key_name[ICMAP_KEYNAME_MAXLEN];
 	static char formated_err[256];
@@ -469,6 +493,13 @@ static int main_config_parser_cb(const char *path,
 				icmap_set_uint32(path, i);
 				add_as_string = 0;
 			}
+			if (strcmp(path, "totem.config_version") == 0) {
+				if (str_to_ull(value, &ull) != 0) {
+					goto atoi_error;
+				}
+				icmap_set_uint64(path, ull);
+				add_as_string = 0;
+			}
 			if (strcmp(path, "totem.crypto_type") == 0) {
 				if ((strcmp(value, "nss") != 0) &&
 				    (strcmp(value, "aes256") != 0)) {