[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
13/27: libutil: Limit readLink() error to only overflows.
From: |
Ludovic Courtès |
Subject: |
13/27: libutil: Limit readLink() error to only overflows. |
Date: |
Wed, 03 Jun 2015 22:00:39 +0000 |
civodul pushed a commit to branch nix
in repository guix.
commit 0b9c4a8b80b199ce82ca5bd08ed24b8d5d5c71f5
Author: aszlig <address@hidden>
Date: Fri Jan 2 03:45:47 2015 +0100
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 <address@hidden>
Tested-by: John Ericson <address@hidden>
---
nix/libutil/util.cc | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc
index 410d0f2..dab4235 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);
}
- 02/27: Use PR_SET_PDEATHSIG to ensure child cleanup, (continued)
- 02/27: Use PR_SET_PDEATHSIG to ensure child cleanup, Ludovic Courtès, 2015/06/03
- 04/27: Get rid of unnecessary "interrupted by the user" message with -vvv, Ludovic Courtès, 2015/06/03
- 03/27: Remove tabs, Ludovic Courtès, 2015/06/03
- 07/27: Shut up a Valgrind warning, Ludovic Courtès, 2015/06/03
- 06/27: Fix some memory leaks, Ludovic Courtès, 2015/06/03
- 08/27: Silence some warnings on GCC 4.9, Ludovic Courtès, 2015/06/03
- 09/27: Better error message, Ludovic Courtès, 2015/06/03
- 10/27: Explicitly include required C headers, Ludovic Courtès, 2015/06/03
- 05/27: Ensure we're writing to stderr in the builder, Ludovic Courtès, 2015/06/03
- 12/27: libutil: Improve errmsg on readLink size mismatch., Ludovic Courtès, 2015/06/03
- 13/27: libutil: Limit readLink() error to only overflows.,
Ludovic Courtès <=
- 11/27: Pedantry, Ludovic Courtès, 2015/06/03
- 14/27: Set /nix/store permission to 1737, Ludovic Courtès, 2015/06/03
- 16/27: Doh^2, Ludovic Courtès, 2015/06/03
- 17/27: Simplify printHash32, Ludovic Courtès, 2015/06/03
- 18/27: Simplify parseHash32, Ludovic Courtès, 2015/06/03
- 19/27: Use pivot_root in addition to chroot when possible, Ludovic Courtès, 2015/06/03
- 15/27: Doh, Ludovic Courtès, 2015/06/03
- 22/27: Tighten permissions on chroot directories, Ludovic Courtès, 2015/06/03
- 20/27: Use chroots for all derivations, Ludovic Courtès, 2015/06/03
- 25/27: Revert /nix/store permission back to 01775, Ludovic Courtès, 2015/06/03