diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2012-06-18 08:55:01 +0300 |
---|---|---|
committer | Martin Pärtel <martin.partel@gmail.com> | 2012-06-18 08:55:01 +0300 |
commit | 8c3c4b93b63812923ed0a24e771b0422b679309e (patch) | |
tree | e08a3e5a7e7880255ceb7f81322589d2c6576c7a | |
parent | a25089ff290d7c3abb7694accda66f007281603f (diff) | |
download | bindfs-8c3c4b93b63812923ed0a24e771b0422b679309e.tar.gz |
Fixed a memory error in src/usermap.c.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/bindfs.c | 1 | ||||
-rw-r--r-- | src/usermap.c | 12 |
3 files changed, 15 insertions, 3 deletions
@@ -1,3 +1,8 @@ +2012-06-18 Martin Pärtel <martin dot partel at gmail dot com> + + * Added --valgrind support to tests/test_bindfs.rb. + * Fixed a memory error. + 2012-05-18 Martin Pärtel <martin dot partel at gmail dot com> * Fixed regression of --create-as-user. Added test case. diff --git a/src/bindfs.c b/src/bindfs.c index 5d7974d..ded13be 100644 --- a/src/bindfs.c +++ b/src/bindfs.c @@ -399,7 +399,6 @@ static int bindfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, struct dirent *de; struct stat st; int result = 0; - (void) path; de_buf = malloc(offsetof(struct dirent, d_name) + pathconf(path, _PC_NAME_MAX) + 1); diff --git a/src/usermap.c b/src/usermap.c index 0cffa33..f745e74 100644 --- a/src/usermap.c +++ b/src/usermap.c @@ -44,7 +44,11 @@ UsermapStatus usermap_add_uid(UserMap *map, uid_t from, uid_t to) return usermap_status_ok; } if (map->user_size == map->user_capacity) { - map->user_capacity *= 2; + if (map->user_capacity == 0) { + map->user_capacity = 8; + } else { + map->user_capacity *= 2; + } map->user_from = (uid_t*)realloc(map->user_from, map->user_capacity * sizeof(uid_t)); map->user_to = (uid_t*)realloc(map->user_to, map->user_capacity * sizeof(uid_t)); } @@ -65,7 +69,11 @@ UsermapStatus usermap_add_gid(UserMap *map, gid_t from, gid_t to) return usermap_status_ok; } if (map->group_size == map->group_capacity) { - map->group_capacity *= 2; + if (map->group_capacity == 0) { + map->group_capacity = 8; + } else { + map->group_capacity *= 2; + } map->group_from = (gid_t*)realloc(map->group_from, map->group_capacity * sizeof(gid_t)); map->group_to = (gid_t*)realloc(map->group_to, map->group_capacity * sizeof(gid_t)); } |