Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix is_mounted (memory leaks and NULL access) #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/encfs_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@

bool is_mounted(const char *mount_dir)
{
struct mntent *m;
FILE *f = setmntent("/etc/mtab", "r");
char *mount_dir_expanded = realpath(mount_dir, NULL);
if (mount_dir_expanded == NULL) {
// no such file or dir, ...
// so: not mounted
// perror("cryptkeeper, is_mounted");
char *mount_dir_expanded, *mnt_dir_expanded;

if (!(mount_dir_expanded = realpath(mount_dir, NULL)))
return false;
}
for (;;) {
char *mnt_dir_expanded;
struct mntent *m = getmntent(f);
if (!m) break;
mnt_dir_expanded = realpath(m->mnt_dir, NULL);
if (strcmp(mount_dir_expanded, mnt_dir_expanded)==0) {

while(m = getmntent(f)) {
if(mnt_dir_expanded = realpath(m->mnt_dir, NULL)) {
if (strcmp(mount_dir_expanded, mnt_dir_expanded)==0) {
free(mnt_dir_expanded);
free(mount_dir_expanded);
return true;
}
free(mnt_dir_expanded);
return true;
}
}
}
free(mount_dir_expanded);
return false;
}

Expand Down