summaryrefslogtreecommitdiff
path: root/zen/symlink_target.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2023-07-24 15:08:16 -0400
committerB. Stack <bgstack15@gmail.com>2023-07-24 15:08:16 -0400
commit69e12f5bd10459ff7c239b82519107ae2a755bc0 (patch)
tree8b22393241df7e46686c9426140582bd747a6d5a /zen/symlink_target.h
parentadd upstream 12.4 (diff)
downloadFreeFileSync-69e12f5bd10459ff7c239b82519107ae2a755bc0.tar.gz
FreeFileSync-69e12f5bd10459ff7c239b82519107ae2a755bc0.tar.bz2
FreeFileSync-69e12f5bd10459ff7c239b82519107ae2a755bc0.zip
add upstream 12.5
Diffstat (limited to 'zen/symlink_target.h')
-rw-r--r--zen/symlink_target.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/zen/symlink_target.h b/zen/symlink_target.h
index 8580a9dd..24ce2313 100644
--- a/zen/symlink_target.h
+++ b/zen/symlink_target.h
@@ -50,7 +50,10 @@ SymlinkRawContent getSymlinkRawContent_impl(const Zstring& linkPath) //throw Sys
const ssize_t bytesWritten = ::readlink(linkPath.c_str(), buf.data(), bufSize);
if (bytesWritten < 0)
THROW_LAST_SYS_ERROR("readlink");
- if (makeUnsigned(bytesWritten) >= bufSize) //detect truncation; not an error for readlink!
+
+ ASSERT_SYSERROR(makeUnsigned(bytesWritten) <= bufSize); //better safe than sorry
+
+ if (makeUnsigned(bytesWritten) == bufSize) //detect truncation; not an error for readlink!
throw SysError(formatSystemError("readlink", L"", L"Buffer truncated."));
return {.targetPath = Zstring(buf.data(), bytesWritten)}; //readlink does not append 0-termination!
bgstack15