]> git.meshlink.io Git - meshlink/commitdiff
Fix reception of a trailing, zero-length frame.
authorGuus Sliepen <guus@meshlink.io>
Wed, 27 May 2020 19:09:00 +0000 (21:09 +0200)
committerGuus Sliepen <guus@meshlink.io>
Wed, 27 May 2020 19:19:07 +0000 (21:19 +0200)
If the last (or only) frame received on a framed UDP channel had zero length,
we would not send it to the application, but keep it in the receive buffer
until more frames had been received.

src/utcp.c

index d068d45b20ccd01d4f9e1b43f01e7becac95cdc3..00e02f6eb7244578d8a9d5c04b342ede293e3913 100644 (file)
@@ -1444,11 +1444,11 @@ static void handle_unreliable_framed(struct utcp_connection *c, const struct hdr
        buffer_clear(&c->rcvbuf);
 
        // Handle whole frames
-       while(left > 2) {
+       while(left >= 2) {
                uint16_t framelen;
                memcpy(&framelen, ptr, sizeof(framelen));
 
-               if(left <= (size_t)framelen + 2) {
+               if(left < (size_t)framelen + 2) {
                        break;
                }