Fix corruption when we parse multiple packets form a single buffer.
This commit is contained in:
@@ -117,10 +117,13 @@ static void receive_read(struct peer *peer) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (receive->buf.length) {
|
||||||
struct packet packet = {
|
struct packet packet = {
|
||||||
.source_id = receive->id,
|
.source_id = receive->id,
|
||||||
};
|
};
|
||||||
while (receive->buf.length && receive->parser_wrapper(receive, &packet)) {
|
if (!receive->parser_wrapper(receive, &packet)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (packet.type == PACKET_TYPE_NONE) {
|
if (packet.type == PACKET_TYPE_NONE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user