From 70802529cd20f1d35680413af993e9acb73f5c65 Mon Sep 17 00:00:00 2001 From: "shegaoyuan@aliyun.com" Date: Thu, 21 Nov 2024 11:50:13 +0800 Subject: [PATCH] fix, force to 32bit nonce adjust for different platform --- finder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/finder.c b/finder.c index 65a41f9..a00bc1d 100644 --- a/finder.c +++ b/finder.c @@ -117,7 +117,7 @@ static void udp_ev_read_cb(struct mg_connection *c, int ev, void *ev_data, void if ( cJSON_IsString(service) && mg_casecmp(cJSON_GetStringValue(service), priv->cfg.opts->service) == 0 \ && cJSON_IsString(finder) && mg_casecmp(cJSON_GetStringValue(finder), priv->cfg.finder_id) \ && cJSON_IsString(payload) && cJSON_IsNumber(nonce) && cJSON_IsString(sign) \ - && nonce->valueint + 60 > mg_millis() / 1000 ) { //只处理60s内的回复,防止重放攻击 + && nonce->valueint + 60 > (int32_t)(mg_millis() / 1000) ) { //只处理60s内的回复,防止重放攻击 MG_INFO(("%.*s <- %s", c->recv.len, (char *)c->recv.buf, remote)); @@ -248,7 +248,7 @@ static void do_broadcast(void *arg, void *address) { } setsockopt(FD(c), SOL_SOCKET, SO_BROADCAST, &flag, sizeof(flag)); - uint64_t nonce = mg_millis()/1000; + int32_t nonce = (int32_t)(mg_millis()/1000); root = cJSON_CreateObject(); cJSON_AddStringToObject(root, "service", priv->cfg.opts->service);