summary refs log tree commit diff
path: root/nix
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2015-01-02 03:45:47 +0100
committerLudovic Courtès <ludo@gnu.org>2015-06-03 18:20:44 +0200
commit0b9c4a8b80b199ce82ca5bd08ed24b8d5d5c71f5 (patch)
tree474dcf8ad98aa2671ebf2ac7e9182288c705b2a4 /nix
parent0fed5fde65e4a0cd600dc181e5b3c42d1147df51 (diff)
downloadguix-0b9c4a8b80b199ce82ca5bd08ed24b8d5d5c71f5.tar.gz
libutil: Limit readLink() error to only overflows.
Let's not just improve the error message itself, but also the behaviour
to actually work around the ntfs-3g symlink bug. If the readlink() call
returns a smaller size than the stat() call, this really isn't a problem
even if the symlink target really has changed between the calls.

So if stat() reports the size for the absolute path, it's most likely
that the relative path is smaller and thus it should also work for file
system bugs as mentioned in 93002d69fc58c2b71e2dfad202139230c630c53a.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Tested-by: John Ericson <Ericson2314@Yahoo.com>
Diffstat (limited to 'nix')
-rw-r--r--nix/libutil/util.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc
index 410d0f2830..dab4235b04 100644
--- a/nix/libutil/util.cc
+++ b/nix/libutil/util.cc
@@ -196,8 +196,8 @@ Path readLink(const Path & path)
     ssize_t rlsize = readlink(path.c_str(), buf, st.st_size);
     if (rlsize == -1)
         throw SysError(format("reading symbolic link '%1%'") % path);
-    else if (rlsize != st.st_size)
-        throw Error(format("symbolic link '%1%' size mismatch %2% != %3%")
+    else if (rlsize > st.st_size)
+        throw Error(format("symbolic link ‘%1%’ size overflow %2% > %3%")
             % path % rlsize % st.st_size);
     return string(buf, st.st_size);
 }