Source: e2fsprogs
Version: 1.43~WIP.2016.03.15-2
Severity: important
Tags: patch
Usertags: hurd
User: [email protected]
Hello,
The latest version of e2fsprogs FTBFS on GNU/Hurd due to three issues:
1) Hurd has fuse-support via hurd-libfuse. However, it is not compatible with
the GNU/Linux version of libfuse.
2) GNU/Hurd does not define FS_IOC_FIEMAP as done in fiemap.h which is included
in files misc/{e4defrag.c,filefrag.c, create_inode.c}. The last two are compiled
on Hurd.
3) PATH_MAX is not defined on GNU/Hurd.
1) is fixed with the first attached patch, debian_rules.patch to disable build
of fuse2fs.
2) is fixed by the second patch, lib_ext2fs_fiemap.h.patch, by undefining
FS_IOC_FIEMAP for Hurd in fiemap.h. It seems like that header file is linux
specific, and is part of the linux kernel headers: /usr/include/linux/{fs.h,
fiemap.h}. Maybe this file should be conditionally included, with corresponding
code block changes in the above two .c files.
3) is fixed by the third patch, misc_create_inode.c.patch, which for the S_IFLNK
case, instead of using PATH_MAX, use the st.st_size entry from the already made
lstat() call in the while loop in the recursive called function __populate_fs().
(I really hope there aren't any problems reusing the lstat() call in that loop,
otherwise one have to make a separate call to another instance of struct stat)
Thanks!--- a/debian/rules.orig 2015-11-21 15:55:51.000000000 +0100
+++ b/debian/rules 2016-04-22 16:01:55.000000000 +0200
@@ -163,6 +163,9 @@
ifeq ($(UTIL_LINUX_NG),yes)
UTIL_CONF_FLAGS ?= --disable-fsck --disable-libblkid \
--disable-libuuid --disable-uuidd
+ifeq ($(DEB_BUILD_GNU_SYSTEM), gnu)
+UTIL_CONF_FLAGS += --disable-fuse2fs
+endif
else
UTIL_CONF_FLAGS ?= --enable-fsck --enable-libblkid \
--enable-libuuid --enable-uuidd
Index: e2fsprogs-1.43~WIP.2016.03.15/lib/ext2fs/fiemap.h
===================================================================
--- e2fsprogs-1.43~WIP.2016.03.15.orig/lib/ext2fs/fiemap.h
+++ e2fsprogs-1.43~WIP.2016.03.15/lib/ext2fs/fiemap.h
@@ -34,9 +34,13 @@ struct fiemap {
struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
};
+#ifndef __GNU__
#ifndef FS_IOC_FIEMAP
#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
#endif
+#else
+#undef FS_IOC_FIEMAP
+#endif
#define FIEMAP_MAX_OFFSET (~0ULL)
Index: e2fsprogs-1.43~WIP.2016.03.15/misc/create_inode.c
===================================================================
--- e2fsprogs-1.43~WIP.2016.03.15.orig/misc/create_inode.c
+++ e2fsprogs-1.43~WIP.2016.03.15/misc/create_inode.c
@@ -687,7 +687,7 @@ static errcode_t __populate_fs(ext2_fils
DIR *dh;
struct dirent *dent;
struct stat st;
- char ln_target[PATH_MAX];
+ char *ln_target = NULL;
unsigned int save_inode;
ext2_ino_t ino;
errcode_t retval = 0;
@@ -754,8 +754,14 @@ static errcode_t __populate_fs(ext2_fils
}
break;
case S_IFLNK:
+ ln_target = malloc(st.st_size + 1);
+ if (ln_target == NULL) {
+ com_err(__func__, retval,
+ _("malloc failed"));
+ goto out;
+ }
read_cnt = readlink(name, ln_target,
- sizeof(ln_target) - 1);
+ st.st_size + 1);
if (read_cnt == -1) {
retval = errno;
com_err(__func__, retval,
@@ -763,9 +769,16 @@ static errcode_t __populate_fs(ext2_fils
name);
goto out;
}
+ if (read_cnt > st.st_size) {
+ com_err(__func__, retval,
+ _("symlink increased in size "
+ "between lstat() and readlink()"));
+ goto out;
+ }
ln_target[read_cnt] = '\0';
retval = do_symlink_internal(fs, parent_ino, name,
ln_target, root);
+ free(ln_target);
if (retval) {
com_err(__func__, retval,
_("while writing symlink\"%s\""),