summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-08-21 23:27:38 +0000
committerGerald Carter <jerry@samba.org>2002-08-21 23:27:38 +0000
commit39966b7e167736e34874fc0523298877490e0a65 (patch)
tree814779373b13b39d013f8c5607c6be814219c8d9
parent474c1489699cb36e5831e6546aef496404a45752 (diff)
downloadsamba-39966b7e167736e34874fc0523298877490e0a65.tar.gz
samba-39966b7e167736e34874fc0523298877490e0a65.tar.bz2
samba-39966b7e167736e34874fc0523298877490e0a65.zip
fix segfault
(This used to be commit 982eadf73bb3932ec3ac89c6112a8bf79dbec127)
-rw-r--r--source3/libsmb/namecache.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/source3/libsmb/namecache.c b/source3/libsmb/namecache.c
index e69d462268..88dbcf218d 100644
--- a/source3/libsmb/namecache.c
+++ b/source3/libsmb/namecache.c
@@ -29,7 +29,7 @@ static TDB_CONTEXT *namecache_tdb;
struct nc_value {
time_t expiry; /* When entry expires */
int count; /* Number of addresses */
- struct in_addr *ip_list; /* Address list */
+ struct in_addr ip_list[1]; /* Address list */
};
/* Initialise namecache system */
@@ -94,14 +94,14 @@ static TDB_DATA namecache_value(struct in_addr *ip_list, int num_names,
int size;
size = sizeof(struct nc_value) + sizeof(struct in_addr) *
- num_names;
+ (num_names-1);
value = (struct nc_value *)malloc(size);
value->expiry = expiry;
value->count = num_names;
- memcpy(value->ip_list, ip_list, num_names * sizeof(struct in_addr));
+ memcpy(value->ip_list, ip_list, size);
retval.dptr = (char *)value;
retval.dsize = size;
@@ -210,10 +210,10 @@ BOOL namecache_fetch(const char *name, int name_type, struct in_addr **ip_list,
/* Extract and return namelist */
*ip_list = (struct in_addr *)malloc(
- sizeof(struct in_addr) * data->count);
+ sizeof(struct in_addr) * (data->count-1));
memcpy(*ip_list, data->ip_list, sizeof(struct in_addr) *
- data->count);
+ (data->count-1));
*num_names = data->count;