Package: graphicsmagick
Version: 1.3.5-5
Severity: important
Tags: patch
Hello,
graphicsmagick currently FTBFS on hurd-i386 because it unconditionally
uses PATH_MAX, while POSIX says that this may not be defined when there
is no such limitation in the system, which is the case for the Hurd. The
attached patch fixes this.
Samuel
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1,
'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.30 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
--
Samuel Thibault <[email protected]>
<O> ?a peut ?tre une madeleine ? sous munitions (avec des composants,
par exemple)
-+- #runtime -+-
--- graphicsmagick-1.3.5.orig/magick/utility.c
+++ graphicsmagick-1.3.5/magick/utility.c
@@ -1255,32 +1255,52 @@
some other systems use compatible schemes.
*/
int
- length;
+ length,
+ ret;
long
pid;
char
- link_path[MaxTextExtent],
- real_path[PATH_MAX+1];
+ link_path[MaxTextExtent];
+
+ char *
+ real_path = NULL;
+
+ struct stat
+ linkbuf;
pid=(long) getpid();
/* Linux format */
FormatString(link_path,"/proc/%ld/exe",pid);
- length=readlink(link_path, real_path, PATH_MAX);
- if (length == -1)
+ ret = lstat(link_path, &linkbuf);
+ if (ret == 0)
+ {
+ real_path = malloc(linkbuf.st_size + 1);
+ length=readlink(link_path, real_path, linkbuf.st_size);
+ }
+ if ((ret != 0) || (length == -1))
{
/* Try FreeBSD format */
FormatString(link_path,"/proc/%ld/file",pid);
- length=readlink(link_path, real_path, PATH_MAX);
+ ret = lstat(link_path, &linkbuf);
+ if (ret == 0)
+ {
+ real_path = realloc(real_path, linkbuf.st_size + 1);
+ length=readlink(link_path, real_path, linkbuf.st_size);
+ }
}
- if ((length > 0) && (length <= PATH_MAX))
+ if ((ret == 0) && (length > 0) && (length <= linkbuf.st_size))
{
real_path[length]=0;
if (strlcpy(path,real_path,MaxTextExtent) < MaxTextExtent)
if (IsAccessible(path))
- return(MagickPass);
+ {
+ free(real_path);
+ return(MagickPass);
+ }
}
+ free(real_path);
}
#endif
return(MagickFail);