]> git.meshlink.io Git - utcp/blobdiff - utcp.c
Handle incoming packets that don't fit into the receive buffer.
[utcp] / utcp.c
diff --git a/utcp.c b/utcp.c
index fd507f91abecc9d674ab99c0cb47ef1d94b1f96e..75d4f83417a3be30bccc6346757abef8f7643585 100644 (file)
--- a/utcp.c
+++ b/utcp.c
@@ -1046,8 +1046,14 @@ static void handle_out_of_order(struct utcp_connection *c, uint32_t offset, cons
        // Packet loss or reordering occured. Store the data in the buffer.
        ssize_t rxd = buffer_put_at(&c->rcvbuf, offset, data, len);
 
-       if(rxd < 0 || (size_t)rxd < len) {
-               abort();
+       if(rxd <= 0) {
+               debug(c, "packet outside receive buffer, dropping\n");
+               return;
+       }
+
+       if((size_t)rxd < len) {
+               debug(c, "packet partially outside receive buffer\n");
+               len = rxd;
        }
 
        // Make note of where we put it.
@@ -1169,10 +1175,6 @@ static void handle_incoming_data(struct utcp_connection *c, const struct hdr *hd
 
        uint32_t offset = seqdiff(hdr->seq, c->rcv.nxt);
 
-       if(offset + len > c->rcvbuf.maxsize) {
-               abort();
-       }
-
        if(offset) {
                handle_out_of_order(c, offset, data, len);
        } else {