mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-01 20:57:54 +00:00
Fix pbuf_memcmp() implementation by using pbuf_try_get_at() instead of pbuf_get_at(). Payload out-of-bounds access was not handled correctly.
This commit is contained in:
parent
23147b0e21
commit
4325aca0f7
@ -1310,8 +1310,11 @@ pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n)
|
|||||||
if ((q != NULL) && (q->len > start)) {
|
if ((q != NULL) && (q->len > start)) {
|
||||||
u16_t i;
|
u16_t i;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
u8_t a = pbuf_get_at(q, start + i);
|
|
||||||
u8_t b = ((const u8_t*)s2)[i];
|
u8_t b = ((const u8_t*)s2)[i];
|
||||||
|
int a = pbuf_try_get_at(q, start + i);
|
||||||
|
if (a < 0) {
|
||||||
|
return 0xffff;
|
||||||
|
}
|
||||||
if (a != b) {
|
if (a != b) {
|
||||||
return i+1;
|
return i+1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user