commit 12e30ce560c2b79f2de9ab7f44626063c0e7e2ff
Author: Oswald Buddenhagen <o...@users.sf.net>
Date:   Mon Jul 29 12:05:43 2024 +0200

    cap readsz at buffer size
    
    otherwise we may get negative comparison sizes, which the unsigned
    arithmetic we use cannot represent. this would prevent buffer content
    downshifting, resulting in prepare_read() erroring out.
    
    amends 859b7dd.
    
    REFMAIL: 87h740x2xe....@wavexx.thregr.org
    REFMAIL: ec0f6f2a-0151-46ad-865a-a6f77ad8e...@app.fastmail.com
    REFMAIL: 87edk45p9o....@b3l.xyz
    REFMAIL: cyawiddgrht7.2ch3r3d6z3...@ferdinandy.com

 src/socket.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/socket.c b/src/socket.c
index 52cd7c2..afd3f18 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -908,8 +908,11 @@ socket_fill( conn_t *sock )
                // IIR filter for tracking average size of bulk reads.
                // We use this to optimize the free space at the end of the
                // buffer, hence the factor of 1.5.
-               if (n >= MIN_BULK_READ)
+               if (n >= MIN_BULK_READ) {
                        sock->readsz = (sock->readsz * 3 + n * 3 / 2) / 4;
+                       if (sock->readsz > sizeof(sock->buf))
+                               sock->readsz = sizeof(sock->buf);
+               }
 
                socket_filled( sock, (uint)n );
        }


_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to