summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flist.c19
-rw-r--r--hashtable.c2
-rw-r--r--rsync.h2
3 files changed, 22 insertions, 1 deletions
diff --git a/flist.c b/flist.c
index f485aca4..0554b5d7 100644
--- a/flist.c
+++ b/flist.c
@@ -638,7 +638,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
int alloc_len, basename_len, linkname_len;
int extra_len = file_extra_cnt * EXTRA_LEN;
int first_hlink_ndx = -1;
- OFF_T file_length;
+ int64 file_length;
const char *basename;
struct file_struct *file;
alloc_pool_t *pool;
@@ -837,8 +837,14 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
if (always_checksum && S_ISREG(mode))
extra_len += SUM_EXTRA_CNT * EXTRA_LEN;
+#if SIZEOF_INT64 >= 8
if (file_length > 0xFFFFFFFFu && S_ISREG(mode))
extra_len += EXTRA_LEN;
+#endif
+ if (file_length < 0) {
+ rprintf(FERROR, "Offset underflow: file-length is negative\n");
+ exit_cleanup(RERR_UNSUPPORTED);
+ }
if (inc_recurse && S_ISDIR(mode)) {
if (one_file_system) {
@@ -871,10 +877,17 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
#endif
file->modtime = (time_t)modtime;
file->len32 = (uint32)file_length;
+#if SIZEOF_INT64 >= 8
if (file_length > 0xFFFFFFFFu && S_ISREG(mode)) {
+#if SIZEOF_CAPITAL_OFF_T < 8
+ rprintf(FERROR, "Offset overflow: attempted 64-bit file-length\n");
+ exit_cleanup(RERR_UNSUPPORTED);
+#else
file->flags |= FLAG_LENGTH64;
OPT_EXTRA(file, 0)->unum = (uint32)(file_length >> 32);
+#endif
}
+#endif
file->mode = mode;
if (preserve_uid)
F_OWNER(file) = uid;
@@ -1163,8 +1176,10 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
linkname_len = 0;
#endif
+#if SIZEOF_CAPITAL_OFF_T >= 8
if (st.st_size > 0xFFFFFFFFu && S_ISREG(st.st_mode))
extra_len += EXTRA_LEN;
+#endif
#if EXTRA_ROUNDING > 0
if (extra_len & (EXTRA_ROUNDING * EXTRA_LEN))
@@ -1209,10 +1224,12 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
file->flags = flags;
file->modtime = st.st_mtime;
file->len32 = (uint32)st.st_size;
+#if SIZEOF_CAPITAL_OFF_T >= 8
if (st.st_size > 0xFFFFFFFFu && S_ISREG(st.st_mode)) {
file->flags |= FLAG_LENGTH64;
OPT_EXTRA(file, 0)->unum = (uint32)(st.st_size >> 32);
}
+#endif
file->mode = st.st_mode;
if (uid_ndx) /* Check uid_ndx instead of preserve_uid for del support */
F_OWNER(file) = st.st_uid;
diff --git a/hashtable.c b/hashtable.c
index 8f0a6181..d2f5948b 100644
--- a/hashtable.c
+++ b/hashtable.c
@@ -104,7 +104,9 @@ void *hashtable_find(struct hashtable *tbl, int64 key, int allocate_if_missing)
a = b = c = 0xdeadbeef + (8 << 2);
#define rot(x,k) (((x)<<(k)) ^ ((x)>>(32-(k))))
+#if SIZEOF_INT64 >= 8
b += (uint32)(key >> 32);
+#endif
a += (uint32)key;
c ^= b; c -= rot(b, 14);
a ^= c; a -= rot(c, 11);
diff --git a/rsync.h b/rsync.h
index aa33a4b9..a600152d 100644
--- a/rsync.h
+++ b/rsync.h
@@ -497,10 +497,12 @@ typedef unsigned int size_t;
#if SIZEOF_OFF_T == 8 || !SIZEOF_OFF64_T || !defined HAVE_STRUCT_STAT64
#define OFF_T off_t
#define STRUCT_STAT struct stat
+#define SIZEOF_CAPITAL_OFF_T SIZEOF_OFF_T
#else
#define OFF_T off64_t
#define STRUCT_STAT struct stat64
#define USE_STAT64_FUNCS 1
+#define SIZEOF_CAPITAL_OFF_T SIZEOF_OFF64_T
#endif
/* CAVEAT: on some systems, int64 will really be a 32-bit integer IFF