Package: libsvg
Version: 0.1.4
Severity: important
Tags: patch

libsvg fails to build on Hurd. There is no MAXPATHLEN in Hurd, because Hurd 
doesn't impose path length limitations.
Please see failed build log: 
http://buildd.debian-ports.org/fetch.php?&pkg=libsvg&ver=0.1.4-2&arch=hurd-i386&stamp=1191625588&file=log&as=raw
Patch attached below to correct this.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: hurd-i386 (i686-AT386)

Kernel: GNU-Mach 1.3.99/Hurd-0.3
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash
--- orig/libsvg-0.1.4/src/svg.c	2008-05-05 20:01:05.000000000 +0000
+++ libsvg-0.1.4/src/svg.c	2008-05-05 20:25:10.890000000 +0000
@@ -206,7 +206,13 @@
 	    void		*closure)
 {
     svg_status_t status;
-    char orig_dir[MAXPATHLEN];
+    char* orig_dir = NULL;
+#ifndef __GLIBC__
+    long pathmax = pathconf("/", _PC_PATH_MAX);
+
+    if (pathmax < 0) /* unlimited path length */
+       pathmax = 1024;
+#endif
 
     if (svg->group_element == NULL)
 	return SVG_STATUS_SUCCESS;
@@ -216,13 +222,27 @@
        directory -- at least I'll be nice about it and restore it
        afterwards. */
 
-    getcwd (orig_dir, MAXPATHLEN);
+#ifdef __GLIBC__
+    orig_dir = getcwd (NULL, 0);
+#else
+    orig_dir = (char *) malloc (pathmax);
+#endif
+
+    if (orig_dir == NULL)
+       return SVG_STATUS_NO_MEMORY;
+
+#ifndef __GLIBC__
+    getcwd (orig_dir, pathmax);
+#endif
+
     chdir (svg->dir_name);
     
     status = svg_element_render (svg->group_element, engine, closure);
 
     chdir (orig_dir);
 
+    free(orig_dir);
+
     return status;
 }
 

Reply via email to