Bug#661527: Apparently a bug in libmount1
I think this is a bug in libmount1. The function mnt_chdir_to_parent() in
util-linux-2.20.1/libmount/src/utils.c fails to handle paths of the form
/dir correctly. The following patch for the source package util-linux should
fix this:
--- util-linux-2.20.1.orig/libmount/src/utils.c 2011-10-18 07:41:47.000000000 +0200
+++ util-linux-2.20.1/libmount/src/utils.c 2012-10-10 21:07:40.559854007 +0200
@@ -69,7 +69,7 @@
*/
int mnt_chdir_to_parent(const char *target, char **filename)
{
- char *path, *last = NULL;
+ char *path, *path2, *last = NULL;
char cwd[PATH_MAX];
int rc = -EINVAL;
@@ -85,11 +85,14 @@
if (!last)
goto err;
}
- if (!*path)
- *path = '/'; /* root */
- if (chdir(path) == -1) {
- DBG(UTILS, mnt_debug("failed to chdir to %s: %m", path));
+ if (*path)
+ path2 = path;
+ else
+ path2 = "/"; /* root */
+
+ if (chdir(path2) == -1) {
+ DBG(UTILS, mnt_debug("failed to chdir to %s: %m", path2));
rc = -errno;
goto err;
}
@@ -98,12 +101,12 @@
rc = -errno;
goto err;
}
- if (strcmp(cwd, path) != 0) {
- DBG(UTILS, mnt_debug("path moved (%s -> %s)", path, cwd));
+ if (strcmp(cwd, path2) != 0) {
+ DBG(UTILS, mnt_debug("path moved (%s -> %s)", path2, cwd));
goto err;
}
- DBG(CXT, mnt_debug("current directory moved to %s", path));
+ DBG(CXT, mnt_debug("current directory moved to %s", path2));
*filename = path;
Reply to: