The attached patch fixes compilation on GNU/Hurd.

Ludo’.

>From 3cab3e40166bfb549ca3ee2a1f20df9f82842d08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <l...@gnu.org>
Date: Mon, 8 Jun 2015 17:27:56 +0200
Subject: [PATCH] Do not rely on PATH_MAX when reading a symlink target.

* src/util.c (move_file): Use 'fromst->st_size + 1' for the allocation,
  and 'fromst->st_size' instead of PATH_MAX.  Fixes compilation
  on GNU/Hurd.
---
 src/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util.c b/src/util.c
index 82a7e37..e061f09 100644
--- a/src/util.c
+++ b/src/util.c
@@ -460,12 +460,12 @@ move_file (char const *from, bool *from_needs_removal,
 
 	  /* FROM contains the contents of the symlink we have patched; need
 	     to convert that back into a symlink. */
-	  char *buffer = xmalloc (PATH_MAX);
+	  char *buffer = xmalloc (fromst->st_size + 1);
 	  int fd, size = 0, i;
 
 	  if ((fd = safe_open (from, O_RDONLY | O_BINARY, 0)) < 0)
 	    pfatal ("Can't reopen file %s", quotearg (from));
-	  while ((i = read (fd, buffer + size, PATH_MAX - size)) > 0)
+	  while ((i = read (fd, buffer + size, fromst->st_size - size)) > 0)
 	    size += i;
 	  if (i != 0 || close (fd) != 0)
 	    read_fatal ();
-- 
2.2.1

Reply via email to