summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-08-21 18:15:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:15 -0500
commitca885cb2d1b0165a6e8c819b82ad9d13de9643ec (patch)
tree7447055f7f210c5154cbb6b7a0e61270d0129c10 /source4
parent0be0e8effc47b45c85023e3628b45543c14972cb (diff)
downloadsamba-ca885cb2d1b0165a6e8c819b82ad9d13de9643ec.tar.gz
samba-ca885cb2d1b0165a6e8c819b82ad9d13de9643ec.tar.bz2
samba-ca885cb2d1b0165a6e8c819b82ad9d13de9643ec.zip
r1989: fixed a couple of bugs in code that assumes sizeof(time_t) == sizeof(int)
(This used to be commit cc3d420c33152c8e9026dc39a7322d11edb3c774)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/gencache.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/source4/lib/gencache.c b/source4/lib/gencache.c
index f3740e3e12..1a66d8dc3d 100644
--- a/source4/lib/gencache.c
+++ b/source4/lib/gencache.c
@@ -250,13 +250,15 @@ BOOL gencache_get(const char *keystr, char **valstr, time_t *timeout)
char* entry_buf = strndup(databuf.dptr, databuf.dsize);
char *v;
time_t t;
+ unsigned i;
v = (char*)malloc(sizeof(char) *
(databuf.dsize - TIMEOUT_LEN));
SAFE_FREE(databuf.dptr);
- sscanf(entry_buf, CACHE_DATA_FMT, (int*)&t, v);
+ sscanf(entry_buf, CACHE_DATA_FMT, (int*)&i, v);
SAFE_FREE(entry_buf);
+ t = i;
DEBUG(10, ("Returning %s cache entry: key = %s, value = %s, "
"timeout = %s\n", t > time(NULL) ? "valid" :
@@ -307,6 +309,7 @@ void gencache_iterate(void (*fn)(const char* key, const char *value, time_t time
TDB_DATA databuf;
char *keystr = NULL, *valstr = NULL, *entry = NULL;
time_t timeout = 0;
+ unsigned i;
/* fail completely if get null pointers passed */
SMB_ASSERT(fn && keystr_pattern);
@@ -335,7 +338,8 @@ void gencache_iterate(void (*fn)(const char* key, const char *value, time_t time
entry = strndup(databuf.dptr, databuf.dsize);
SAFE_FREE(databuf.dptr);
valstr = (char*)malloc(sizeof(char) * (databuf.dsize - TIMEOUT_LEN));
- sscanf(entry, CACHE_DATA_FMT, (int*)(&timeout), valstr);
+ sscanf(entry, CACHE_DATA_FMT, (int*)(&i), valstr);
+ timeout = i;
DEBUG(10, ("Calling function with arguments (key = %s, value = %s, timeout = %s)\n",
keystr, valstr, ctime(&timeout)));