aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-06-21 12:49:18 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-06-21 12:53:52 +0200
commit29ccb2e9697ee2184012dd13854e487928ae4441 (patch)
treec06c8b6f8a8a86a4bb39323e3b4d27bdd29562c7 /src/libexpr/primops
parentd0a769cb061a13ad880c76e5ea69a76150439853 (diff)
Fix 32-bit overflow with --no-net
--no-net causes tarballTtl to be set to the largest 32-bit integer, which causes comparison like 'time + tarballTtl < other_time' to fail on 32-bit systems. So cast them to 64-bit first. https://hydra.nixos.org/build/95076624
Diffstat (limited to 'src/libexpr/primops')
-rw-r--r--src/libexpr/primops/fetchGit.cc2
-rw-r--r--src/libexpr/primops/fetchMercurial.cc13
2 files changed, 6 insertions, 9 deletions
diff --git a/src/libexpr/primops/fetchGit.cc b/src/libexpr/primops/fetchGit.cc
index 10f6b6f72..f0f5b2a51 100644
--- a/src/libexpr/primops/fetchGit.cc
+++ b/src/libexpr/primops/fetchGit.cc
@@ -135,7 +135,7 @@ GitInfo exportGit(ref<Store> store, std::string uri,
git fetch to update the local ref to the remote ref. */
struct stat st;
doFetch = stat(localRefFile.c_str(), &st) != 0 ||
- st.st_mtime + settings.tarballTtl <= now;
+ (uint64_t) st.st_mtime + settings.tarballTtl <= (uint64_t) now;
}
if (doFetch) {
diff --git a/src/libexpr/primops/fetchMercurial.cc b/src/libexpr/primops/fetchMercurial.cc
index 596047ce3..c791443c3 100644
--- a/src/libexpr/primops/fetchMercurial.cc
+++ b/src/libexpr/primops/fetchMercurial.cc
@@ -77,7 +77,7 @@ HgInfo exportMercurial(ref<Store> store, const std::string & uri,
time_t now = time(0);
struct stat st;
if (stat(stampFile.c_str(), &st) != 0 ||
- st.st_mtime + settings.tarballTtl <= now)
+ (uint64_t) st.st_mtime + settings.tarballTtl <= (uint64_t) now)
{
/* Except that if this is a commit hash that we already have,
we don't have to pull again. */
@@ -93,17 +93,14 @@ HgInfo exportMercurial(ref<Store> store, const std::string & uri,
try {
runProgram("hg", true, { "pull", "-R", cacheDir, "--", uri });
}
- catch (ExecError & e){
+ catch (ExecError & e) {
string transJournal = cacheDir + "/.hg/store/journal";
/* hg throws "abandoned transaction" error only if this file exists */
- if (pathExists(transJournal))
- {
+ if (pathExists(transJournal)) {
runProgram("hg", true, { "recover", "-R", cacheDir });
runProgram("hg", true, { "pull", "-R", cacheDir, "--", uri });
- }
- else
- {
- throw ExecError(e.status, fmt("program hg '%1%' ", statusToString(e.status)));
+ } else {
+ throw ExecError(e.status, fmt("'hg pull' %s", statusToString(e.status)));
}
}
} else {