summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-06-15 21:03:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:17:28 -0500
commit835bfbb8ac6a6239299a22a9e79643674a0a75e2 (patch)
tree084127a37fc92a118cd1a06e6188139fa804edec /source3/utils
parente942ca4e0a2a28ad5132abb2bf165f064d792c44 (diff)
downloadsamba-835bfbb8ac6a6239299a22a9e79643674a0a75e2.tar.gz
samba-835bfbb8ac6a6239299a22a9e79643674a0a75e2.tar.bz2
samba-835bfbb8ac6a6239299a22a9e79643674a0a75e2.zip
r16267: Fix Klocwork #401, #402 - ensure format specifier
limited. Fix memleak in printing gencache contents. Jeremy. (This used to be commit 81731e1f68cdf4af80733338238aeae0a7d108c0)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_cache.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/source3/utils/net_cache.c b/source3/utils/net_cache.c
index 69b3327f7a..b90befcca2 100644
--- a/source3/utils/net_cache.c
+++ b/source3/utils/net_cache.c
@@ -38,6 +38,7 @@ static void print_cache_entry(const char* keystr, const char* datastr,
const time_t timeout, void* dptr)
{
char *timeout_str;
+ char *alloc_str = NULL;
time_t now_t = time(NULL);
struct tm timeout_tm, *now_tm;
/* localtime returns statically allocated pointer, so timeout_tm
@@ -64,12 +65,18 @@ static void print_cache_entry(const char* keystr, const char* datastr,
}
timeout_str[strlen(timeout_str) - 1] = '\0'; /* remove tailing CR */
} else {
- asprintf(&timeout_str, "%.2d:%.2d:%.2d", timeout_tm.tm_hour,
+ asprintf(&alloc_str, "%.2d:%.2d:%.2d", timeout_tm.tm_hour,
timeout_tm.tm_min, timeout_tm.tm_sec);
+ if (!alloc_str) {
+ return;
+ }
+ timeout_str = alloc_str;
}
d_printf("Key: %s\t Timeout: %s\t Value: %s %s\n", keystr,
timeout_str, datastr, timeout > now_t ? "": "(expired)");
+
+ SAFE_FREE(alloc_str);
}
static void delete_cache_entry(const char* keystr, const char* datastr,