From 8b21b4a4ad105047d30e51734f1e28f8e9a0f58c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 2 Nov 2011 18:12:34 +0530 Subject: [PATCH] calibre-mount-helper: Refuse to mount anythin under /usr, /bin or /sbin --- src/calibre/devices/linux_mount_helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/calibre/devices/linux_mount_helper.c b/src/calibre/devices/linux_mount_helper.c index cf22e4112f..79c974f915 100644 --- a/src/calibre/devices/linux_mount_helper.c +++ b/src/calibre/devices/linux_mount_helper.c @@ -44,6 +44,12 @@ int do_mount(const char *dev, const char *mp) { fprintf(stderr, "Specified device node does not exist\n"); return EXIT_FAILURE; } + + if (strncmp("/usr", mp, 4) == 0 || strncmp("/bin", mp, 4) == 0 || strncmp("/sbin", mp, 5) == 0) { + fprintf(stderr, "Trying to mount to a mount point under /usr, /bin, /sbin is not allowed\n"); + return EXIT_FAILURE; + } + if (!exists(mp)) { if (mkdir(mp, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) != 0) { errsv = errno;