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

Try to fix #35 #36

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 4 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
19 changes: 10 additions & 9 deletions patches/libfuse/mount.c.diff
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
diff --git a/lib/mount.c b/lib/mount.c
index d71e6fc55..acc1711ff 100644
--- a/lib/mount.c
+++ b/lib/mount.c
@@ -41,7 +41,6 @@
Expand All @@ -10,7 +8,7 @@ index d71e6fc55..acc1711ff 100644
#define FUSE_COMMFD_ENV "_FUSE_COMMFD"

#ifndef HAVE_FORK
@@ -117,17 +116,79 @@ static const struct fuse_opt fuse_mount_opts[] = {
@@ -117,17 +116,81 @@
FUSE_OPT_END
};

Expand Down Expand Up @@ -65,8 +63,10 @@ index d71e6fc55..acc1711ff 100644
+ // For i = 4...99, check if there is a binary called "fusermount" + i
+ // It is not yet known whether this will work for our purposes, but it is better than not even attempting
+ for (int i = 4; i < 100; i++) {
+ prog = findBinaryInFusermountDir("fusermount" + i);
+ if (access(prog, X_OK) == 0)
+ char binaryName[20];
+ sprintf(binaryName, "fusermount%d", i);
probonopd marked this conversation as resolved.
Show resolved Hide resolved
+ prog = findBinaryInFusermountDir(binaryName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use snprintf which takes the size into account:

Suggested change
+ sprintf(binaryName, "fusermount%d", i);
+ sprintf(binaryName, sizeof(binaryName) "fusermount%d", i);

You should further check the size of the return value:

if (snprintf(...) >= 13)
# alternativelly, since you expect a single digit
if (snprintf(...) != 11)

Copy link
Member Author

@probonopd probonopd Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fusermount4... fusermount99 is what I had in mind

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean with the further check - in which case would this even be needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i overflows for whatever reason (might be future changes), snprintf will not render additional digits but it'd be unexpected to run into the limit anyway. It's good practice to check the return value. See, e.g., https://stackoverflow.com/questions/54084570/how-to-detect-snprintf-errors.

+ if (prog && access(prog, X_OK) == 0)
+ return prog;
probonopd marked this conversation as resolved.
Show resolved Hide resolved
+ }
+
Expand All @@ -93,7 +93,7 @@ index d71e6fc55..acc1711ff 100644
exec_fusermount(argv);
_exit(1);
} else if (pid != -1)
@@ -300,7 +361,7 @@ void fuse_kern_unmount(const char *mountpoint, int fd)
@@ -300,7 +363,7 @@
return;

if(pid == 0) {
Expand All @@ -102,7 +102,7 @@ index d71e6fc55..acc1711ff 100644
"--", mountpoint, NULL };

exec_fusermount(argv);
@@ -346,7 +407,7 @@ static int setup_auto_unmount(const char *mountpoint, int quiet)
@@ -346,7 +409,7 @@
}
}

Expand All @@ -111,7 +111,7 @@ index d71e6fc55..acc1711ff 100644
argv[a++] = "--auto-unmount";
argv[a++] = "--";
argv[a++] = mountpoint;
@@ -407,7 +468,7 @@ static int fuse_mount_fusermount(const char *mountpoint, struct mount_opts *mo,
@@ -407,7 +470,7 @@
}
}

Expand All @@ -120,11 +120,12 @@ index d71e6fc55..acc1711ff 100644
if (opts) {
argv[a++] = "-o";
argv[a++] = opts;
@@ -421,7 +482,7 @@ static int fuse_mount_fusermount(const char *mountpoint, struct mount_opts *mo,
@@ -421,7 +484,7 @@
snprintf(env, sizeof(env), "%i", fds[0]);
setenv(FUSE_COMMFD_ENV, env, 1);
exec_fusermount(argv);
- perror("fuse: failed to exec fusermount3");
+ perror("fuse: failed to exec fusermount");
_exit(1);
}

Loading