From 8f21a5da81d6553a314b7b52981edaac4ca517ff Mon Sep 17 00:00:00 2001 From: lemoer Date: Wed, 18 May 2016 21:20:47 +0200 Subject: [PATCH] pong handler: add sanity check for rtt --- src/protocol_misc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/protocol_misc.c b/src/protocol_misc.c index b2695436..154f2c85 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -137,6 +137,12 @@ bool pong_h(connection_t *c, const char *request) { tv_usec = c->last_ping_time.tv_usec; } + if (_now.tv_sec - tv_sec > 2*pingtimeout) { + /* timeout_handler should close the meta connection after pingtimeout. + * So if we still receive such pong, something is fishy. */ + logger(DEBUG_ALWAYS, LOG_ERR, "bogus pong received from %s (%s)", c->name, c->hostname); + return false; + } /* RTT should be in ms */ current_rtt = (_now.tv_sec - tv_sec)*1000; /* Compute diff between usec */