• src/sbbs3/writemsg.cpp

    From rswindell to CVS commit on Tuesday, May 12, 2020 23:40:20
    src/sbbs3 writemsg.cpp 1.173 1.174
    Update of /cvsroot/sbbs/src/sbbs3
    In directory cvs:/tmp/cvs-serv11411

    Modified Files:
    writemsg.cpp
    Log Message:
    Use binary mode when creating quotes.txt to eliminate excessive carriage return characters on Windows.

  • From rswindell to CVS commit on Sunday, May 24, 2020 12:34:02
    src/sbbs3 writemsg.cpp 1.174 1.175
    Update of /cvsroot/sbbs/src/sbbs3
    In directory cvs:/tmp/cvs-serv28131

    Modified Files:
    writemsg.cpp
    Log Message:
    Fix heap corruption resulting from use of internal message editor "/E" (edit line) command when extended a line of text to a length longer than what was allocated.

  • From Rob Swindell to Git commit to sbbs/master on Wednesday, October 21, 2020 18:32:09
    https://gitlab.synchro.net/sbbs/sbbs/-/commit/eb209e8495db39e7732696fc
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Do not remove trailing white-space from lines in .sig files

    This allows a .sig file to contain "\n-- \n", the "standard" USENET signature delimiter, as requested by Tracker1.
  • From Rob Swindell to Git commit to main/sbbs/master on Wednesday, December 09, 2020 02:02:49
    https://gitlab.synchro.net/main/sbbs/-/commit/97ac3bbf7720b3940d3f3198
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Parse/separate forward-to-netmail name from address

    Only do the local user notification when appropriate.
    Signal the FTN netmail semaphore when appropriate.
  • From Rob Swindell to Git commit to main/sbbs/master on Friday, March 05, 2021 20:41:25
    https://gitlab.synchro.net/main/sbbs/-/commit/3e999815c58affc0eefcf7fb
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Don't allow subject to be changed when forwarding file attachments

    Since the filename is in the subject, we can't allow the user to change the subject (duh). Also, don't bother with the "Fwd:" prefix thing as that could potentially cause problems in other places where the filename (only) is assumed to be in the subject.

    Also, make sure to create the destination directory when moving file attachments. These changes fix issue #230 reported by Keyop.
  • From Rob Swindell to Git commit to main/sbbs/master on Saturday, March 13, 2021 12:48:15
    https://gitlab.synchro.net/main/sbbs/-/commit/5b044471b7f5dd69840fcb04
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Fix error removing INPUT.MSG introduced in Commit 0c441424

    remove() is expected to fail in this scenario sometimes depending
    on how writemsg() is used - in the error case, the user was trying
    to edit his .plan file with the ;plan command:
    term Node 10 <Deuce> !ERROR 11 (Resource temporarily unavailable) in writemsg.cpp line 1232 (editfile) removing "/sbbs/node10/temp/INPUT.MSG" access=0

    Thanks for the bug report!
  • From Rob Swindell to Git commit to main/sbbs/master on Wednesday, March 31, 2021 23:56:36
    https://gitlab.synchro.net/main/sbbs/-/commit/1f805a5d3f87786be3c576cd
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Fix editmsg() always fails bug introduced in commit 0c441424

    Another Coverity-issued-fixed-introduced-bug.

    Failure to remove a non-existant file is not reason for failure.
  • From Rob Swindell to Git commit to main/sbbs/master on Sunday, April 25, 2021 19:36:21
    https://gitlab.synchro.net/main/sbbs/-/commit/1139cfe5ab831096a0b94cef
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Fix double close (fnopen doesn't leave the descriptor open)

    Fixes CID 33724.
  • From Rob Swindell to Git commit to main/sbbs/master on Tuesday, August 17, 2021 23:49:55
    https://gitlab.synchro.net/main/sbbs/-/commit/4d01818374e0bb40b1fa15ba
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    When writing/reading quotes.txt, ignore first 2 lines if WWIV-type

    WWIV writes 2 lines of metadata to the beginning of its quotes.txt file created for external message editors. Its not clear yet what these lines should contain, but the first line apparently should contain a '#' character since BREdit checks for this character before deciding to throw-away/ignore these lines (don't use them for quoted text). Thanks mlong for this tip!

    So if the external editor is set to "WWIV CHAIN.TXT" in SCFG (even if the door doesn't need/use it), then the quotes.txt file created by Synchronet will contain the extra 2 lines. We're just writing a # to the first line and the second line is blank.

    This fixes reported issue #188.
  • From Rob Swindell to Git commit to main/sbbs/master on Wednesday, March 02, 2022 13:25:51
    https://gitlab.synchro.net/main/sbbs/-/commit/b47b97c2602bdd784b0f63dc
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Detect smb_[f]allocdat() failure in editmsg()

    CID 319091
  • From Rob Swindell to Git commit to main/sbbs/master on Wednesday, March 02, 2022 18:14:50
    https://gitlab.synchro.net/main/sbbs/-/commit/bb18309c7f0cde12745b44ff
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Fix CID 33239: Argument cannot be negative
  • From Rob Swindell to Git commit to main/sbbs/master on Sunday, March 13, 2022 00:18:52
    https://gitlab.synchro.net/main/sbbs/-/commit/da406c0a793ce998e982dd88
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Fix CID 33235: Argument cannot be negative
  • From Rob Swindell to Git commit to main/sbbs/master on Sunday, July 03, 2022 15:55:50
    https://gitlab.synchro.net/main/sbbs/-/commit/2db618ae2da445cf21a420c5
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Fix smb.subnum corruption in writemsg()

    Fix issue introduced 9 years ago that could cause a crash after replying to a post via email or netmail and then displaying the header of a poll message or a normal message with votes:

    Program terminated with signal SIGSEGV, Segmentation fault.
    #0 0x00007f9f9569a317 in sbbs_t::show_msg (this=0x7f9f70c56880,
    smb=0x7f9f70c5e4e0, msg=0x7f9ebadf08b0, p_mode=4, post=0x7f9f18071a24)
    at getmsg.cpp:255
    255 ,cfg.sub[smb->subnum]->misc&SUB_ NAME ? useron.name : useron.alias, NET_NONE, NULL);
    [Current thread is 1 (Thread 0x7f9ebadf3700 (LWP 23279))]
    (gdb) print smb->subnum
    $1 = 4294967295
    (gdb) bt
    #0 0x00007f9f9569a317 in sbbs_t::show_msg (this=0x7f9f70c56880,
    smb=0x7f9f70c5e4e0, msg=0x7f9ebadf08b0, p_mode=4, post=0x7f9f18071a24)
    at getmsg.cpp:255
    #1 0x00007f9f957b2aee in sbbs_t::scanposts (this=0x7f9f70c56880, subnum=9,
    mode=2, find=0x7f9ebadf1270 "") at readmsgs.cpp:670
    #2 0x00007f9f957bb75a in sbbs_t::scanallsubs (this=0x7f9f70c56880, mode=2)
    at scansubs.cpp:219
    #3 0x00007f9f9568c948 in sbbs_t::exec_msg (this=0x7f9f70c56880,
    csi=0x7f9f70c64768) at execmsg.cpp:315
    #4 0x00007f9f95683129 in sbbs_t::exec_function (this=0x7f9f70c56880,
    csi=0x7f9f70c64768) at execfunc.cpp:422
    #5 0x00007f9f95679450 in sbbs_t::exec (this=0x7f9f70c56880,
    csi=0x7f9f70c64768) at exec.cpp:1199
    #6 0x00007f9f9577d742 in node_thread (arg=0x7f9f70c56880) at main.cpp:4364

    writemsg() was changing the global smb.subnum and when writing an email or netmail, that subnum value is -1 (since it's not a sub-board) and then later show_msg() is using the smb.subnum as a index into scfg.sub[] when determining if the current user already voted on the message being displayed and then: bang, crash, fall down, go boom.

    Simply saving and restoring the smb.subnum when executing an external editor is all that was needed here. And this is the first use of the C++ "auto" keyword in Synchronet!
  • From Rob Swindell (on Debian Linux) to Git commit to main/sbbs/master on Tuesday, February 07, 2023 18:11:57
    https://gitlab.synchro.net/main/sbbs/-/commit/208cc78b54ac851645e8cbd1
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Don't save draft messages upon disconnect for Guest or "no one" (user #0)

    Fix issue #508
  • From Rob Swindell (on Windows) to Git commit to main/sbbs/master on Thursday, April 13, 2023 18:45:54
    https://gitlab.synchro.net/main/sbbs/-/commit/ff3864002e9a51e98b1c83f5
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Bounds-check the buffer being written in msgeditor()

    Replace the suspicious strcpy/strcat's in msgeditor(), the built-in line editor, with bounds-enforced snprintf() calls.
    Also, properly define MAX_LINE_LEN to account for the trailing \r\n on each line. It appears we've been under allocating the total possible message buffer size (by 2 bytes per line) for a while now.
    These 2 changes together should fix issue #547: apparent heap corruption due
    to 'buf' overflow in msgeditor().
    Also added a line count check/cap-enforcement with logged error message if exceeded (should never happen).

    Also fixed in this commit: off-by-one when enforcing max message length in msgeditor().

    Also added checks that the 'cols' (used in MAX_LINE_LEN) are reasonable values (40+), 2 was below the threshold of what would be expected to work since
    there is logic that deducts 4 from cols, for example.
  • From Rob Swindell (on Windows) to Git commit to main/sbbs/master on Thursday, April 13, 2023 18:45:54
    https://gitlab.synchro.net/main/sbbs/-/commit/2d9f8a32c55c82016b13d0a1
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    When writing messages with a 'top' in raw-input-mode, don't add excessive CRLF

    If the top already ends in a blank line, no additional CRLF is warranted (between the 'top' and the raw-input message 'body').
  • From Rob Swindell (on Debian Linux) to Git commit to main/sbbs/master on Thursday, April 13, 2023 18:47:22
    https://gitlab.synchro.net/main/sbbs/-/commit/84527be03f4d728bafe58f10
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Fix new GCC warning in printf format string.
  • From Rob Swindell (on Windows) to Git commit to main/sbbs/master on Friday, April 14, 2023 20:37:52
    https://gitlab.synchro.net/main/sbbs/-/commit/4f9a8b209a160d8fac1fc4a3
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Address a couple of Coverity-reported defects

    CID 452331
    CID 452330
  • From Rob Swindell (on Windows 11) to Git commit to main/sbbs/master on Thursday, December 21, 2023 12:38:45
    https://gitlab.synchro.net/main/sbbs/-/commit/daf8fa55aa08b39bf8b4fc6e
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Fix internal line editor buffer overflow (heap corruption)

    ... wasn't accounting for length of the 'top' buffer (when supplied).

    Also, for raw input mode:
    - flush the input buffer (stray LF) before accepting input
    - turn off raw input mode if run out of bytes (max lines/length reached)

    I was investigating the reported error by Nelgin:
    !ERROR in writemsg.cpp line 1214 (msgeditor) checking
    "max lines (20) exceeded" access=46
    which I was unable to reproduce, when I encountered the issues addressed
    in this commit.
  • From Rob Swindell (on Windows 11) to Git commit to main/sbbs/master on Tuesday, December 26, 2023 16:04:06
    https://gitlab.synchro.net/main/sbbs/-/commit/3057bcc20148e3d93d1052a5
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Insure uploaded text ends in a new-line

    We were appending .sig files to uploaded text, which may not have ended
    in an LF or CRLF sequence. This fixes that.
  • From Rob Swindell (on Windows 11) to Git commit to main/sbbs/master on Friday, December 29, 2023 17:10:28
    https://gitlab.synchro.net/main/sbbs/-/commit/ee5e3e8ee949f73113909680
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Fix an error path FILE* leak (CID 462238)

    Go ahead and fix false-positive CID 33482 by adding a NULL check to quotestr()
  • From Rob Swindell (on Windows 11) to Git commit to main/sbbs/master on Tuesday, January 23, 2024 18:37:49
    https://gitlab.synchro.net/main/sbbs/-/commit/1321d7f537df2b0eb0c99f33
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    When editing a message, pass the proper to/from/subj/area to drop file

    Fixes issue #704 - not just for JS bbs.edit_msg(), but for all uses of the underlying sbbs_t::editmsg() function.

    Replaced one specific comparison of subnum == INVALID_SUB with call to is_valid_subnum() just to be consistent. No functional change there.
  • From Rob Swindell (on Windows 11) to Git commit to main/sbbs/master on Tuesday, February 13, 2024 20:37:50
    https://gitlab.synchro.net/main/sbbs/-/commit/00afb97cc670fdf3e11aa839
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Improvements to UTF-8 capable external editor support

    1. Add an 8th line to MSGINF (for SlyEdit): the character set expected
    (either "CP437", the default, or "UTF-8") based on the SCFG configuration
    2. Don't apply "Soft-CR" (0x8D) stripping/expansion for UTF-8 editors
  • From Rob Swindell (on Windows 11) to Git commit to main/sbbs/master on Thursday, February 15, 2024 19:24:53
    https://gitlab.synchro.net/main/sbbs/-/commit/0dc20c1f9bf66ae376b0f22d
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    If the quotes.txt file doesn't exist with the right case, try any case

    (but prefer the proper/configured case, based on config in SCFG).

    Works around a problem where DDMsgReader always creates QUOTES.TXT (never quotes.txt), but SBBS tries to read in the file with the case it expects.
    This wouldn't be a problem on case-insensitive file systems (Windows).

    Resolves the writemsg.cpp error reported by Nelgin
  • From Rob Swindell (on Windows 11) to Git commit to main/sbbs/master on Thursday, February 15, 2024 21:37:00
    https://gitlab.synchro.net/main/sbbs/-/commit/f894f62108ad3251bfcba84c
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Fix bug in previous commit to this file

    I'm surprised this didn't create a warning somewhere: treating char* as a
    bool!
  • From Rob Swindell (on Debian Linux) to Git commit to main/sbbs/master on Tuesday, February 20, 2024 23:57:53
    https://gitlab.synchro.net/main/sbbs/-/commit/f754ad9057b0cd076bcf57b1
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Allow UTF-8 sequences in message subjects (passing K_UTF8 to getstr)

    This was the behavior for all string input in SBBS until recently
    (Commit 55ccda6294f82506), with this change, an exception is being
    made for message subjects, but the vast majority of other string
    input is still limited to single-byte (i.e. US-ASCII or CP437)
    characters.

    This should fix issue #720
  • From Rob Swindell (on Windows 11) to Git commit to main/sbbs/master on Saturday, September 21, 2024 13:08:41
    https://gitlab.synchro.net/main/sbbs/-/commit/10beb091cd05d255e3911a80
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Log a file "create" error if process_edited_file() returns a negative value

    I discovered that sbbs_t::editfile() (exposed as JS console.editfile) just silently failed if it couldn't write to the destination file
    (e.g. permission denied by OS).
  • From Rob Swindell (on Windows 11) to Git commit to main/sbbs/master on Monday, November 04, 2024 17:37:33
    https://gitlab.synchro.net/main/sbbs/-/commit/e3f17e6411aba06d9894b169
    Modified Files:
    src/sbbs3/writemsg.cpp
    Log Message:
    Internal message/line editor improvements

    * Allow left and right arrow keys to move between lines (within reason)
    * Use the K_USEOFFSET getstr() mode flag to keep cursor position when moving
    between lines with arrow keys
    * Be smart about integer padding when /Listing lines with numbers
    * Add range checking (!) and better error reporting for /Lx argument value