Hello,

I  forgot   the  modification  i   have  made  into  the   zum.c  source
file. Therefore, this patch fix this oversight.

Regards,
Arnaud Fontaine

diff -urN perforate-1.2.old/zum.c perforate-1.2/zum.c
--- perforate-1.2.old/zum.c     2006-03-09 12:25:35.000000000 +0100
+++ perforate-1.2/zum.c 2006-03-10 00:37:45.000000000 +0100
@@ -5,6 +5,11 @@
  * 2005-11-11: Wouter Verhelst <[EMAIL PROTECTED]>: clean up the code a bit (so
  *     that it no longer produces any warnings, add large file support.
  *
+ * 2006-03-10: Arnaud Fontaine <[EMAIL PROTECTED]>: replace fgets by
+ * getline in main function (we use dynamic memory allocation instead
+ * of MAXPATHLEN macro which doesn't exist on Debian GNU/Hurd and
+ * optional in POSIX).
+ *
  * This code is covered by General Public License, version 2 or any later
  * version of your choice. You should recieve file "COPYING" which contains
  * text of the license with any distribution of this program; if you don't 
@@ -13,6 +18,7 @@
 
 #define _FILE_OFFSET_BITS 64
 #define _LARGEFILE_SOURCE
+#define _GNU_SOURCE
 
 #include <stdio.h>
 #include <string.h>
@@ -26,9 +32,45 @@
 #include <utime.h>
 #include <alloca.h>
 #include <unistd.h>
+#include <stdlib.h>
 
 extern int errno;
 
+/* GLibc provides getline, which allocate automatically the right
+   amount for the line, read by *stream. If not available, use
+   ours. */
+#ifdef __GLIBC__
+# define my_getline getline
+#else
+# define GETLINE_CHUNK_SIZE 4096
+
+static ssize_t my_getline(char **lineptr, size_t *n, FILE *stream)
+{
+  if(lineptr == NULL || n == NULL)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
+  if(*n == 0)
+    {
+      *lineptr = malloc(sizeof (char *) * GETLINE_CHUNK_SIZE);
+      *n = GETLINE_CHUNK_SIZE;
+    }
+
+  char *ret = fgets (*lineptr, *n, stream);
+  while(ret != NULL && (*lineptr)[strlen (*lineptr) - 1] != '\n')
+    {
+      *n += GETLINE_CHUNK_SIZE;
+      *lineptr = realloc(*lineptr, sizeof (char *) * *n);
+
+      ret = fgets(*lineptr + strlen (*lineptr), GETLINE_CHUNK_SIZE, stream);
+    }
+
+  return (ret ? strlen (*lineptr) : -1);
+}
+#endif /* !__GLIBC__ */
+
 static char suffix[] = "__zum__";
 
 static void* my_mmap(void *ptr, int fd, off_t size, off_t *pos)
@@ -181,9 +223,13 @@
     while((p = *(++argv)))
       zero_unmap(p);
   else {
-    char buf[MAXPATHLEN];
-    while(fgets(buf, MAXPATHLEN, stdin))
+    char *buf = NULL;
+    size_t len = 0;
+    while(my_getline(&buf, &len, stdin) != -1)
       zero_unmap(buf);
+    
+    if (buf)
+      free(buf);
   }
   return 0;
 }

Reply via email to