• incorrect variable replacement in node_action causes core dump

    From Nigel Reed@1:103/705 to GitLab issue in main/sbbs on Sat Sep 2 13:04:23 2023
    open https://gitlab.synchro.net/main/sbbs/-/issues/612

    ~~~ bbs.replace_text(708,"%s at Multi Relay Chat %s"); bbs.node_action = NODE_BXFR; bbs.nodesync(); bbs.revert_text(708); bbs.exec("?../xtrn/mrc/mrc-client.js",null,"/sbbs/xtrn/mrc/");~~~I was trying to get "via ssh" on the end of the Multi Relay Chat line, adding a %s would cause the terminal to core dump~~~[Thread debugging using libthread_db enabled]Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".--Type <RET> for more, q to quit, c to continue without paging--cCore was generated by `/sbbs/exec/sbbs d'.Program terminated with signal SIGSEGV, Segmentation fault.#0 __strlen_sse2 () at ../sysdeps/x86_64/multiarch/strlen-vec.S:126126 ../sysdeps/x86_64/multiarch/strlen-vec.S: No such file or directory.[Current thread is 1 (Thread 0x7ff1527fc640 (LWP 1052439))](gdb) bt#0 __strlen_sse2 () at ../sysdeps/x86_64/multiarch/strlen-vec.S:126#1 0x00007ff1c7c1cdb1 in __vfprintf_internal (s=s@entry=0x7ff1527f01a0, format=format@entry=0x7ff14816de70 "%s at Multi Relay Chat %s", ap=ap@entry=0x7ff1527f02e0, mode_flags=mode_flags@entry=0) at ./stdio-common/vfprintf-internal.c:1517#2 0x00007ff1c7c27a09 in __vsprintf_internal (string=0x7ff1527f04e0 "Nelgin at Multi Relay Chat ", maxlen=maxlen@entry=18446744073709551615, format=0x7ff14816de70 "%s at Multi Relay Chat %s", args=args@entry=0x7ff1527f02e0, mode_flags=mode_flags@entry=0) at ./libio/iovsprintf.c:95#3 0x00007ff1c7c069a8 in __sprintf (s=<optimized out>, format=<optimized out>) at ./stdio-common/sprintf.c:30#4 0x00007ff1c810dab3 in sbbs_t::putnodedat (this=0x7ff1b4503ac0, number=1, node=0x7ff1b450f7b0) at putnode.cpp:51#5 0x00007ff1c7fe9640 in sbbs_t::nodesync (this=0x7ff1b4503ac0, clearline=false) at getnode.cpp:126#6 0x00007ff1c7ffce2d in js_nodesync (cx=0x7ff14806e6e0, argc=0, arglist=0x7ff1600000a0) at js_bbs.cpp:1282#7 0x00007ff1c84480c7 in js::CallJSNative (vp=0x7ff1600000a0, argc=0, native=0x7ff1c7ffccbc <js_nodesync(JSContext*, uintN, jsval*)>, cx=0x7ff14806e6e0) at /home/bbs/sbbs-test/repo/3rdp/src/mozjs/js-1.8.5/js/src/jscntxtinlines.h:701#8 js::Interpret (cx=0x7ff14806e6e0, entryFrame=0x7ff160000048, inlineCallCount=0, interpMode=JSINTERP_NORMAL) at jsinterp.cpp:4799#9 0x00007ff1c823a5c6 in js::RunScript (cx=0x7ff14806e6e0, script=0x7ff1481eeea0, fp=0x7ff160000048) at /home/bbs/sbbs-test/repo/3rdp/src/mozjs/js-1.8.5/js/src/jsinterp.cpp:653#10 0x00007ff1c823d55f in js::Execute (cx=0x7ff14806e6e0, chain=0x7ff15169ac60, script=0x7ff1481eeea0, prev=0x0, flags=0, result=0x7ff1527f5078) at /home/bbs/sbbs-test/repo/3rdp/src/mozjs/js-1.8.5/js/src/jsinterp.cpp:1028#11 0x00007ff1c819e3a1 in JS_ExecuteScript (cx=0x7ff14806e6e0, obj=0x7ff15169ac60, scriptObj=0x7ff15169aca8, rval=0x7ff1527f5078) at jsapi.cpp:4998#12 0x00007ff1c7fc1971 in sbbs_t::js_execfile (this=0x7ff1b4503ac0, cmd=0x7ff1527fa920 "eotl_chat", startup_dir=0x0, scope=0x0, js_cx=0x7ff14806e6e0, js_glob=0x7ff151603048) at exec.cpp:676#13 0x00007ff1c7fc2014 in sbbs_t::exec_bin (this=0x7ff1b4503ac0, cmdline=0x7ff1527fa920 "eotl_chat", csi=0x7ff1b4515d98, startup_dir=0x0) at exec.cpp:770#14 0x00007ff1c7fc43ef in sbbs_t::exec (this=0x7ff1b4503ac0, csi=0x7ff1b4515d98) at exec.cpp:1331#15 0x00007ff1c80e2938 in node_thread (arg=0x7ff1b4503ac0) at main.cpp:4305#16 0x00007ff1c7c3ab43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442#17 0x00007ff1c7ccca00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81~~~As a follow up, what would the proper value be to include "via ssh" or "via telnet" ?
    --- SBBSecho 3.20-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Rob Swindell@1:103/705 to GitLab note in main/sbbs on Sat Sep 2 13:33:13 2023
    https://gitlab.synchro.net/main/sbbs/-/issues/612#note_3874

    This isn't a bug. The same thing can happen if you use %s incorrect in the ctrl/text.dat file.If you know the value/variable you want in the string, use JS variables to get the value.e.g. `bbs.replace_text(708,"%s at Multi Relay Chat via " + client.protocol); `
    --- SBBSecho 3.20-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Rob Swindell@1:103/705 to GitLab note in main/sbbs on Sat Sep 2 14:06:01 2023
    https://gitlab.synchro.net/main/sbbs/-/issues/612#note_3875

    A little more background: the extended node status has the following replacement variables that must be specified in the following order if/when used: ```sprintf(str,text[NodeActionMain+node->action] ,useron.alias ,useron.level ,getage(&cfg,useron.birth) ,useron.sex ,useron.comp ,useron.ipaddr ,unixtodstr(&cfg,useron.firston,firston) ,node->aux&0xff ,node->connection );```Since useron.level is an integer number (not a string), using %s in its position would be expected to crash the BBS.With this is in mind, it's just much better to put the values you know you want to see in the string itself and not use printf-specifiers (e.g. %s) for variable-replacement.
    --- SBBSecho 3.20-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)