Skip to content

Commit

Permalink
fix, force to 32bit nonce adjust for different platform
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Nov 21, 2024
1 parent 8b05361 commit 7080252
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions finder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7080252

Please sign in to comment.