• Calling word_wrap() with negative length causes a crash (segfault); wi

    From Eric Oulashin@VERT to GitLab issue in main/sbbs on Thu Jun 22 18:21:06 2023
    open https://gitlab.synchro.net/main/sbbs/-/issues/576

    I found this with a build of Synchronet from May 27 (and I'm running in Linux). This was found with a JavaScript script that was calculating a length to use with word_wrap, and the length ended up negative. My script now checks the length to ensure that doesn't happen. However, I found a couple things:
    - Calling word_wrap() with a negative line length causes a crash (segfault)
    - Calling word_wrap() with a length of 0 seems to cause high CPU usage ('top' showed 100% CPU usage by sbbs), and it also didn't seem to finish; perhaps there's an infinite loop in this case?

    To reproduce - Crash/segfault:
    ```
    var aStr = "This is a string that I want to word-wrap for a test.";
    var wrappedStr = word_wrap(aStr, -1);
    ```

    High CPU usage/possible infinite loop:
    ```
    var aStr = "This is a string that I want to word-wrap for a test.";
    var wrappedStr = word_wrap(aStr, 0);
    ```

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Eric Oulashin@VERT to GitLab note in main/sbbs on Thu Jun 22 18:24:17 2023
    https://gitlab.synchro.net/main/sbbs/-/issues/576#note_3624

    Branch created by mistake

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