Skip to content

Commit

Permalink
fix(dns): Fix a bug of the seq number is overflow, if we don't have f…
Browse files Browse the repository at this point in the history
…ound an unused entry and table is full, use the oldest completed one.
  • Loading branch information
lhespress authored and xcguang committed Jan 3, 2020
1 parent 1998485 commit 5c01bde
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion third_party/lwip/core/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,17 @@ dns_enqueue(const char *name, dns_found_callback found, void *callback_arg)
if ((dns_seqno - pEntry->seqno) > lseq) {
lseq = dns_seqno - pEntry->seqno;
lseqi = i;
} else {
if (pEntry->seqno >= (0xFF - DNS_TABLE_SIZE)) {
static u8 index = 0;
if ((pEntry->seqno - (0xFF - DNS_TABLE_SIZE)) == index) {
index ++;
lseqi = i;
if (index == DNS_TABLE_SIZE) {
index = 0;
}
}
}
}
}
}
Expand All @@ -918,13 +929,17 @@ dns_enqueue(const char *name, dns_found_callback found, void *callback_arg)

/* fill the entry */
pEntry->state = DNS_STATE_NEW;
pEntry->seqno = dns_seqno++;
pEntry->seqno = dns_seqno;
pEntry->found = found;
pEntry->arg = callback_arg;
namelen = LWIP_MIN(os_strlen(name), DNS_MAX_NAME_LENGTH-1);
MEMCPY(pEntry->name, name, namelen);
pEntry->name[namelen] = 0;

dns_seqno ++;
if (dns_seqno == 0xFF) {
dns_seqno = 0;
}
/* force to send query without waiting timer */
dns_check_entry(i);

Expand Down

0 comments on commit 5c01bde

Please sign in to comment.