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

    From Eric Oulashin@1:103/705 to GitLab issue in main/sbbs on Thu Jun 22 11: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);```
    --- SBBSecho 3.20-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Eric Oulashin@1:103/705 to GitLab note in main/sbbs on Thu Jun 22 11:24:17 2023
    https://gitlab.synchro.net/main/sbbs/-/issues/576#note_3624

    Branch created by mistake
    --- SBBSecho 3.20-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)