Unverified Commit 169be042 authored by Theo Buehler's avatar Theo Buehler Committed by GitHub
Browse files

Fixes for systems with 64-bit time (#8662)

Some operating systems (e.g., NetBSD and OpenBSD) have switched to
using a 64-bit integer for time_t on all platforms. This results in currently
harmless compiler warnings due to potential truncation.
These changes fix these minor portability concerns.

* Fix format string for systems with 64 bit time
* use llabs to avoid truncation with 64 bit time
parent 6097d14d
...@@ -473,7 +473,7 @@ NULL ...@@ -473,7 +473,7 @@ NULL
} else if (!strcasecmp(c->argv[1]->ptr,"segfault")) { } else if (!strcasecmp(c->argv[1]->ptr,"segfault")) {
*((char*)-1) = 'x'; *((char*)-1) = 'x';
} else if (!strcasecmp(c->argv[1]->ptr,"panic")) { } else if (!strcasecmp(c->argv[1]->ptr,"panic")) {
serverPanic("DEBUG PANIC called at Unix time %ld", time(NULL)); serverPanic("DEBUG PANIC called at Unix time %lld", (long long)time(NULL));
} else if (!strcasecmp(c->argv[1]->ptr,"restart") || } else if (!strcasecmp(c->argv[1]->ptr,"restart") ||
!strcasecmp(c->argv[1]->ptr,"crash-and-recover")) !strcasecmp(c->argv[1]->ptr,"crash-and-recover"))
{ {
......
...@@ -3008,7 +3008,7 @@ void securityWarningCommand(client *c) { ...@@ -3008,7 +3008,7 @@ void securityWarningCommand(client *c) {
static time_t logged_time; static time_t logged_time;
time_t now = time(NULL); time_t now = time(NULL);
if (labs(now-logged_time) > 60) { if (llabs(now-logged_time) > 60) {
serverLog(LL_WARNING,"Possible SECURITY ATTACK detected. It looks like somebody is sending POST or Host: commands to Redis. This is likely due to an attacker attempting to use Cross Protocol Scripting to compromise your Redis instance. Connection aborted."); serverLog(LL_WARNING,"Possible SECURITY ATTACK detected. It looks like somebody is sending POST or Host: commands to Redis. This is likely due to an attacker attempting to use Cross Protocol Scripting to compromise your Redis instance. Connection aborted.");
logged_time = now; logged_time = now;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment