1 From: Don Armstrong <don@debian.org>
2 Subject: Support at least INT_MAX numbers in config
4 Bug-Debian: http://bugs.debian.org/676689
9 unsigned long l = strtoul(str, &p, 10);
10 /* must not overflow int even after x1000 */
11 - if (!*p && l <= INT_MAX / 1000)
12 + /* This is not required with the changes to have a unsigned long ttl */
13 + if (!*p && l <= INT_MAX)
16 error_and_die("malformed or too big number '%s'", str);
19 smallint srv_enable[3];
20 smallint check_files[3];
23 + unsigned long pttl[3];
24 + unsigned long nttl[3];
27 /* We try to closely mimic glibc nscd */
29 return sizeof(user_req_header) + ureq->key_len;
32 -static unsigned cache_age(const user_req *ureq)
33 +static unsigned long cache_age(const user_req *ureq)
35 if (!CACHED_ENTRY(ureq))
37 - return (uint32_t) (g_now_ms - (ureq->timestamp24 << 8));
38 + return (unsigned long) (g_now_ms - (ureq->timestamp24 << 8));
41 static void set_cache_timestamp(user_req *ureq)
45 unsigned oldest_idx = 0;
46 - unsigned oldest_age = 0;
47 + unsigned long oldest_age = 0;
48 for (i = 0; i < 8; i++) {
49 - unsigned age = cache_age(cacheline[i]);
50 + unsigned long age = cache_age(cacheline[i]);
51 if (age > oldest_age) {
58 - log(L_DEBUG, "not found, freeing and reusing cache[%u][%u] (age %u)", hash, i, oldest_age);
59 + log(L_DEBUG, "not found, freeing and reusing cache[%u][%u] (age %ul)", hash, i, oldest_age);
60 free_refcounted_ureq(&cacheline[i]);
63 @@ -1326,11 +1327,11 @@
65 free_refcounted_ureq(cp);
67 - unsigned age = cache_age(cached);
68 + unsigned long age = cache_age(cached);
69 response_header *resp = ureq_response(cached);
70 - unsigned ttl = (resp->found ? config.pttl : config.nttl)[csrv];
71 + unsigned long ttl = (resp->found ? config.pttl : config.nttl)[csrv];
73 - log(L_DEBUG2, "freeing: age %u positive %d ttl %u", age, resp->found, ttl);
74 + log(L_DEBUG2, "freeing: age %ul positive %d ttl %ul", age, resp->found, ttl);
76 free_refcounted_ureq(cp);
77 } else if (srv == -1) {
81 for (n = 0; n < 3; n++) {
82 - log(L_DEBUG, "%s cache enabled:%u pttl:%u nttl:%u",
83 + log(L_DEBUG, "%s cache enabled:%u pttl:%ul nttl:%ul",