From 2f083b85917768bd822eb27585b2ed27b123a728 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Mon, 21 Oct 2013 16:04:31 -0700 Subject: [PATCH] Support at least INT_MAX numbers in config (Closes: #676689) --- debian/changelog | 1 + .../change_invalidate_request_info_output | 2 +- debian/patches/series | 2 +- .../patches/support_large_numbers_in_config | 86 +++++++++++++++++++ 4 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 debian/patches/support_large_numbers_in_config diff --git a/debian/changelog b/debian/changelog index c008b4f..eb74a20 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ unscd (0.51-1) unstable; urgency=low * New upstream release * Silence the cache invalidation output (Closes: #622230) * Update to debhelper 9 + * Support at least INT_MAX numbers in config (Closes: #676689) -- diff --git a/debian/patches/change_invalidate_request_info_output b/debian/patches/change_invalidate_request_info_output index d5dfb17..b4f98a3 100644 --- a/debian/patches/change_invalidate_request_info_output +++ b/debian/patches/change_invalidate_request_info_output @@ -1,6 +1,6 @@ From: Don Armstrong Subject: Silence cache invalidation requests unless in debug mode -Origin: debian, http://websvn.donarmstrong.com/filedetails.php?repname=deb_pkgs&path=%2Funscd%2Ftrunk%2Fdebian%2Fpatches%2Fsilence_cache_invalidation +Origin: debian Bug-Debian: http://bugs.debian.org/622230 --- a/nscd.c +++ b/nscd.c diff --git a/debian/patches/series b/debian/patches/series index c5742c0..ee65dce 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,2 +1,2 @@ change_invalidate_request_info_output - +support_large_numbers_in_config diff --git a/debian/patches/support_large_numbers_in_config b/debian/patches/support_large_numbers_in_config new file mode 100644 index 0000000..3659b6b --- /dev/null +++ b/debian/patches/support_large_numbers_in_config @@ -0,0 +1,86 @@ +From: Don Armstrong +Subject: Support at least INT_MAX numbers in config +Origin: debian +Bug-Debian: http://bugs.debian.org/676689 +--- a/nscd.c ++++ b/nscd.c +@@ -438,7 +438,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); +@@ -510,8 +511,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 */ +@@ -746,11 +747,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) +@@ -1271,9 +1272,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; +@@ -1290,7 +1291,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: +@@ -1317,11 +1318,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) { +@@ -2641,7 +2642,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], -- 2.39.2