summaryrefslogtreecommitdiff
path: root/src/rdb.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2018-06-12 17:21:57 +0200
committerantirez <antirez@gmail.com>2018-06-12 17:22:03 +0200
commitf70e88c1f6e2c7db676ea39dfa323d7c613df787 (patch)
treeee1a091f299d66fc6579aa4809ac85f93aff56d3 /src/rdb.c
parent4774d6169108e96a246d062772022b68601a37e5 (diff)
downloadredis-f70e88c1f6e2c7db676ea39dfa323d7c613df787.tar.gz
RDB: store times consistently in little endian.
I'm not sure how this escaped the attention of Redis users for years, but finally @oranagra reported this issue... Thanks to Oran.
Diffstat (limited to 'src/rdb.c')
-rw-r--r--src/rdb.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/rdb.c b/src/rdb.c
index 5ec06f9a8..7d5fd5fc4 100644
--- a/src/rdb.c
+++ b/src/rdb.c
@@ -100,6 +100,9 @@ int rdbLoadType(rio *rdb) {
return type;
}
+/* This is only used to load old databases stored with the RDB_OPCODE_EXPIRETIME
+ * opcode. New versions of Redis store using the RDB_OPCODE_EXPIRETIME_MS
+ * opcode. */
time_t rdbLoadTime(rio *rdb) {
int32_t t32;
rdbLoadRaw(rdb,&t32,4);
@@ -108,12 +111,14 @@ time_t rdbLoadTime(rio *rdb) {
int rdbSaveMillisecondTime(rio *rdb, long long t) {
int64_t t64 = (int64_t) t;
+ memrev64ifbe(&t64); /* Store in little endian. */
return rdbWriteRaw(rdb,&t64,8);
}
long long rdbLoadMillisecondTime(rio *rdb) {
int64_t t64;
rdbLoadRaw(rdb,&t64,8);
+ memrev64ifbe(&t64); /* Convert in big endian if the system is BE. */
return (long long)t64;
}