summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-01-15 09:28:18 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-01-15 09:28:18 +0000
commit0474f1be4516b74635b21bba729a04273ea31d41 (patch)
tree9be556f5f8912fdd8525e29e10c3a69b4c150c7f
parent6d5a0e912a176b6c2bc8633cacecddecc3c576e2 (diff)
parent2634ebada8f9b099c4b64e7c129f801a3229d7ef (diff)
downloadbsdiff-0474f1be4516b74635b21bba729a04273ea31d41.tar.gz
Merge "Fix A/B update fail for 32-bit devices"
-rw-r--r--bsdiff.gyp3
-rw-r--r--file.cc6
-rw-r--r--include/bsdiff/file_interface.h3
3 files changed, 7 insertions, 5 deletions
diff --git a/bsdiff.gyp b/bsdiff.gyp
index 72444ba..37daa3b 100644
--- a/bsdiff.gyp
+++ b/bsdiff.gyp
@@ -27,6 +27,9 @@
# "bsdiff/...".
'<(platform2_root)/../aosp/external',
],
+ 'defines': [
+ '_FILE_OFFSET_BITS=64',
+ ],
},
'targets': [
# bsdiff static library
diff --git a/file.cc b/file.cc
index 50f8ef1..b232867 100644
--- a/file.cc
+++ b/file.cc
@@ -64,11 +64,7 @@ bool File::Seek(off_t pos) {
errno = EBADF;
return false;
}
- // fseek() uses a long value for the offset which could be smaller than off_t.
- if (pos > std::numeric_limits<long>::max()) {
- errno = EOVERFLOW;
- return false;
- }
+
off_t newpos = lseek(fd_, pos, SEEK_SET);
if (newpos < 0)
return false;
diff --git a/include/bsdiff/file_interface.h b/include/bsdiff/file_interface.h
index 1f33147..fe10e98 100644
--- a/include/bsdiff/file_interface.h
+++ b/include/bsdiff/file_interface.h
@@ -12,6 +12,9 @@
#include "bsdiff/common.h"
+static_assert(sizeof(off_t) == sizeof(int64_t),
+ "off_t must be a 64-bit number, use -D_FILE_OFFSET_BITS=64");
+
namespace bsdiff {
class BSDIFF_EXPORT FileInterface {