Bug#653362: mp4h: FTBFS on hurd-i386
Source: mp4h
Version: 1.3.1-6
Severity: important
Tags: patch
User: debian-hurd@lists.debian.org
Usertags: hurd
Hi,
mp4h FTBFS on GNU/Hurd, see
https://buildd.debian.org/status/fetch.php?pkg=mp4h&arch=hurd-i386&ver=1.3.1-6&stamp=1324166240
This is due to that MATPATHLEN is set to 256 in builtin.h which is far
too short for realpath usage. On GNU/HUrd PATH_MAX is not defined, while
_POSIX_PATH_MAX is and is set to 256 an that constant is used.
During the build of documentation mp4h.html from mp4h.mp4h the end of
the environment vector __envron is overwritten/truncated, removing the
NULL termination of that vector and causing a segfault. The attached
patch fixes these problems by dynamically allocating the resolved
pathname using the canonicalize_file_name() function if available. The
availability is checked in configure.ac. The patch should be placed last
in the series to apply properly.
Thanks!
diff -ur mp4h-1.3.1/configure.ac mp4h-1.3.1.modified/configure.ac
--- mp4h-1.3.1/configure.ac 2011-12-27 12:09:55.000000000 +0100
+++ mp4h-1.3.1.modified/configure.ac 2011-12-27 12:41:20.000000000 +0100
@@ -38,7 +38,7 @@
AC_CHECK_HEADERS([limits.h locale.h memory.h stdarg.h string.h unistd.h time.h])
AC_CHECK_HEADERS([pwd.h grp.h dirent.h sys/param.h sys/stat.h sys/types.h sys/times.h])
-AC_CHECK_FUNCS([mkstemp strchr strerror tmpfile getpwuid getgrgid bcopy memmove])
+AC_CHECK_FUNCS([mkstemp strchr strerror tmpfile getpwuid getgrgid bcopy memmove canonicalize_file_name])
AC_FUNC_ALLOCA
AC_FUNC_VPRINTF
AC_REPLACE_FUNCS(strtol obstack xmalloc xstrdup)
diff -ur mp4h-1.3.1/src/builtin.c mp4h-1.3.1.modified/src/builtin.c
--- mp4h-1.3.1/src/builtin.c 2011-12-27 12:09:56.000000000 +0100
+++ mp4h-1.3.1.modified/src/builtin.c 2011-12-27 12:41:23.000000000 +0100
@@ -1468,7 +1468,11 @@
mp4h_bp_real_path (MP4H_BUILTIN_ARGS)
{
const char *pathname;
+#ifdef HAVE_CANONICALIZE_FILE_NAME
+ char *resolvedname = NULL;
+#else
char resolvedname[MAXPATHLEN];
+#endif
CHECK_SAFETY_LEVEL(1);
@@ -1478,12 +1482,22 @@
_("Warning:%s:%d: In <%s>, required attribute `%s' is not specified"),
CURRENT_FILE_LINE, ARG (0), "pathname"));
else
+#ifdef HAVE_CANONICALIZE_FILE_NAME
+ if ((resolvedname = canonicalize_file_name(pathname)) == NULL)
+#else
if (!realpath(pathname, resolvedname))
+#endif
MP4HERROR ((warning_status, errno,
_("Error:%s:%d: Cannot form real path for `%s'"),
CURRENT_FILE_LINE, pathname));
else
+ {
obstack_grow(obs, resolvedname, strlen(resolvedname));
+#ifdef HAVE_CANONICALIZE_FILE_NAME
+ free(resolvedname);
+#endif
+
+ }
}
#endif /* HAVE_FILE_FUNCS */
Reply to: