From: Don Armstrong <don@debian.org>
Subject: Support at least INT_MAX numbers in config
Origin: debian
Bug-Debian: http://bugs.debian.org/676689
--- a/nscd.c
+++ b/nscd.c
@@ -443,7 +443,8 @@
 		char *p;
 		unsigned long l = strtoul(str, &p, 10);
 		/* must not overflow int even after x1000 */
-		if (!*p && l <= INT_MAX / 1000)
+        /* This is not required with the changes to have a unsigned long ttl */
+		if (!*p && l <= INT_MAX)
 			return l;
 	}
 	error_and_die("malformed or too big number '%s'", str);
@@ -515,8 +516,8 @@
 	const char *user;
 	smallint srv_enable[3];
 	smallint check_files[3];
-	unsigned pttl[3];
-	unsigned nttl[3];
+	unsigned long pttl[3];
+	unsigned long nttl[3];
 	unsigned size[3];
 } config = {
 	/* We try to closely mimic glibc nscd */
@@ -751,11 +752,11 @@
 	return sizeof(user_req_header) + ureq->key_len;
 }
 
-static unsigned cache_age(const user_req *ureq)
+static unsigned long cache_age(const user_req *ureq)
 {
 	if (!CACHED_ENTRY(ureq))
 		return 0;
-	return (uint32_t) (g_now_ms - (ureq->timestamp24 << 8));
+	return (unsigned long) (g_now_ms - (ureq->timestamp24 << 8));
 }
 
 static void set_cache_timestamp(user_req *ureq)
@@ -1280,9 +1281,9 @@
 	}
 
 	unsigned oldest_idx = 0;
-	unsigned oldest_age = 0;
+	unsigned long oldest_age = 0;
 	for (i = 0; i < 8; i++) {
-		unsigned age = cache_age(cacheline[i]);
+		unsigned long age = cache_age(cacheline[i]);
 		if (age > oldest_age) {
 			oldest_age = age;
 			oldest_idx = i;
@@ -1299,7 +1300,7 @@
 		return NULL;
 	}
 	i = oldest_idx;
-	log(L_DEBUG, "not found, freeing and reusing cache[%u][%u] (age %u)", hash, i, oldest_age);
+	log(L_DEBUG, "not found, freeing and reusing cache[%u][%u] (age %ul)", hash, i, oldest_age);
 	free_refcounted_ureq(&cacheline[i]);
 
  ret:
@@ -1326,11 +1327,11 @@
 					cached_cnt--;
 					free_refcounted_ureq(cp);
 				} else {
-                        		unsigned age = cache_age(cached);
+                        		unsigned long age = cache_age(cached);
 					response_header *resp = ureq_response(cached);
-					unsigned ttl = (resp->found ? config.pttl : config.nttl)[csrv];
+					unsigned long ttl = (resp->found ? config.pttl : config.nttl)[csrv];
 					if (age >= ttl) {
-						log(L_DEBUG2, "freeing: age %u positive %d ttl %u", age, resp->found, ttl);
+						log(L_DEBUG2, "freeing: age %ul positive %d ttl %ul", age, resp->found, ttl);
 						cached_cnt--;
 						free_refcounted_ureq(cp);
 					} else if (srv == -1) {
@@ -2650,7 +2651,7 @@
 	}
 
 	for (n = 0; n < 3; n++) {
-		log(L_DEBUG, "%s cache enabled:%u pttl:%u nttl:%u",
+		log(L_DEBUG, "%s cache enabled:%u pttl:%ul nttl:%ul",
 				srv_name[n],
 				config.srv_enable[n],
 				config.pttl[n],
