From 011fdb47728bb6592bd0fb4e83d57a9c852b2495 Mon Sep 17 00:00:00 2001 From: Tibault Damman Date: Mon, 15 Jan 2024 16:48:02 +0100 Subject: [PATCH] fix build on 32bit systems Code had an assert that tests if sizeof(long) == sizeof(long long), which obviously fails on 32-bit architectures. I believe the assert is incorrect on any architecture, considering the following code is actually putting a long long in an _int_. I replaced it with code that checks if the value fits in an int. Signed-off-by: Tibault Damman --- src/replication.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/replication.cpp b/src/replication.cpp index df47cb91a..e009731e8 100644 --- a/src/replication.cpp +++ b/src/replication.cpp @@ -2608,8 +2608,11 @@ bool readSnapshotBulkPayload(connection *conn, redisMaster *mi, rdbSaveInfo &rsi if (mi->parseState->depth() != 0) return false; - static_assert(sizeof(long) == sizeof(long long),""); - rsi.repl_stream_db = mi->parseState->getMetaDataLongLong("repl-stream-db"); + long long repl_stream_db = mi->parseState->getMetaDataLongLong("repl-stream-db"); + if (repl_stream_db < INT_MIN || repl_stream_db > INT_MAX) { + throw "Invalid repl_stream_db value"; + } + rsi.repl_stream_db = static_cast(repl_stream_db); rsi.repl_offset = mi->parseState->getMetaDataLongLong("repl-offset"); sds str = mi->parseState->getMetaDataStr("repl-id"); if (sdslen(str) == CONFIG_RUN_ID_SIZE) {