mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-25 15:42:56 +00:00
dns_compare_name: change check for u16_t overflow
check upper border (0xFFFF) instead of checking for 0 after overflow
This commit is contained in:
parent
d4047ea1d1
commit
bcb6819715
@ -649,10 +649,12 @@ dns_compare_name(const char *query, struct pbuf *p, u16_t start_offset)
|
|||||||
u16_t response_offset = start_offset;
|
u16_t response_offset = start_offset;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
n = pbuf_try_get_at(p, response_offset++);
|
n = pbuf_try_get_at(p, response_offset);
|
||||||
if ((n < 0) || (response_offset == 0)) {
|
if ((n < 0) || (response_offset == 0xFFFF)) {
|
||||||
|
/* error or overflow */
|
||||||
return 0xFFFF;
|
return 0xFFFF;
|
||||||
}
|
}
|
||||||
|
response_offset++;
|
||||||
/** @see RFC 1035 - 4.1.4. Message compression */
|
/** @see RFC 1035 - 4.1.4. Message compression */
|
||||||
if ((n & 0xc0) == 0xc0) {
|
if ((n & 0xc0) == 0xc0) {
|
||||||
/* Compressed name: cannot be equal since we don't send them */
|
/* Compressed name: cannot be equal since we don't send them */
|
||||||
@ -667,10 +669,11 @@ dns_compare_name(const char *query, struct pbuf *p, u16_t start_offset)
|
|||||||
if ((*query) != (u8_t)c) {
|
if ((*query) != (u8_t)c) {
|
||||||
return 0xFFFF;
|
return 0xFFFF;
|
||||||
}
|
}
|
||||||
++response_offset;
|
if (response_offset == 0xFFFF) {
|
||||||
if (response_offset == 0) {
|
/* would overflow */
|
||||||
return 0xFFFF;
|
return 0xFFFF;
|
||||||
}
|
}
|
||||||
|
response_offset++;
|
||||||
++query;
|
++query;
|
||||||
--n;
|
--n;
|
||||||
}
|
}
|
||||||
@ -683,6 +686,7 @@ dns_compare_name(const char *query, struct pbuf *p, u16_t start_offset)
|
|||||||
} while (n != 0);
|
} while (n != 0);
|
||||||
|
|
||||||
if (response_offset == 0xFFFF) {
|
if (response_offset == 0xFFFF) {
|
||||||
|
/* would overflow */
|
||||||
return 0xFFFF;
|
return 0xFFFF;
|
||||||
}
|
}
|
||||||
return (u16_t)(response_offset + 1);
|
return (u16_t)(response_offset + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user