Package: rats
Severity: important
Tags: patch

Dear Maintainer,

rats currently FTBFS on hurd-i386 because of the use of the PATH_MAX macro, 
which is not defined on Hurd. The attached patch should fix this issue.

WBR,
Cyril Roelandt.

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

Kernel: GNU-Mach 1.3.99/Hurd-0.3
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
--- rats-2.3.orig/engine.c	2009-06-29 21:08:26.000000000 +0000
+++ rats-2.3/engine.c	2012-05-13 21:15:33.000000000 +0000
@@ -1051,11 +1051,9 @@
        !strcmp(dirdata->d_name,"..")) {
       continue;
     }
-    buf=calloc(PATH_MAX,1);
-    sprintf(buf,
-	    "%s/%s",
-	    filename,
-	    dirdata->d_name);
+    size_t len = snprintf(NULL, 0, "%s/%s", filename, dirdata->d_name) + 1;
+    buf = calloc(len, 1);
+    snprintf(buf, len, "%s/%s", filename, dirdata->d_name);
     process_file(buf,forcelang);
   }
 #endif
@@ -1093,11 +1091,15 @@
       /* Symbolic link check */
       if(S_ISLNK(fstat.st_mode)) {
         if(flags & FOLLOW_SYMLINK) {
-	  char *symname;
-	  symname=calloc(PATH_MAX,1);
-	  if(readlink(filename,symname,PATH_MAX)==-1) {
-	    return;
-	  }
+          char *symname;
+          struct stat buf;
+          if(lstat(filename, &buf)==-1) {
+            return;
+          }
+          symname=calloc(buf.st_size, 1);
+          if(readlink(filename,symname,buf.st_size)==-1) {
+            return;
+          }
 	  process_file(symname,forcelang);
         }
         return;

Reply via email to