• src/sbbs3/ringbuf.c

    From rswindell@VERT to CVS commit on Monday, August 26, 2019 23:37:52
    src/sbbs3 ringbuf.c 1.31 1.32
    Update of /cvsroot/sbbs/src/sbbs3
    In directory cvs:/tmp/cvs-serv30956

    Modified Files:
    ringbuf.c
    Log Message:
    Implement a simple bound-checker in RingBufWrite():
    if the ringbuf is shared among multiple threads (e.g. the sbbs->outbuf is shared between output_thread() and passthru_thread()) - it was possible
    for a race condition to occur between the caller would call RingBufFree
    to determine the available space in the ringbuf and the call to RingBufWrite which would happily overflow the allocated buffer if more data was
    written to the ringbuf (by another thread) in the unprotected time between the RingBufFree and RingBufWrite calls.

    Now, RingBufWrite() can perform short-writes and will return a length less
    than what was requested to write when there is not enough available space
    to write the requested length.

    Hopefully this resolves the corruption/crash issue Deuce is seeing in
    sbbs's passthru_thread().



    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net