Skip to content
Snippets Groups Projects
  1. Feb 11, 2025
  2. Feb 08, 2025
    • Rob Swindell's avatar
      Native JS methods must return JS_FALSE for (Error) exceptions to be thrown · 6ed4a05f
      Rob Swindell authored
      I discovered the first case when FileBase.get_path() failed, but didn't
      (immediately) throw an exception. Reviewing the other instances of
      JS_RepoertError() calls found several that either reported a garbage (e.g.
      NULL) string value or returned JS_TRUE.
      
      The design pattern used a little in js_socket.c probably should be used more:
      
      	if (JS_IsExceptionPending(cx))
      		return JS_FALSE;
      	return JS_TRUE;
      
      ... but that's more of a refactor than I had the stomach for right now.
      6ed4a05f
  3. Jan 27, 2025
    • Deucе's avatar
      Fix spurious call to JS_THIS_OBJECT() · b580def0
      Deucе authored
      This appears to be why valgrind on FreeBSD was failing.
      You can't actually call this in a constructor because creating
      this is the whole point of calling it.
      b580def0
  4. Jan 14, 2025
  5. Oct 01, 2024
  6. Sep 21, 2024
  7. Sep 14, 2024
    • Rob Swindell's avatar
      Eliminte weird gcc (12.2) warning in release build (only) · 10562789
      Rob Swindell authored
      Increasing size of mode[] element by 2 bytes eliminated these GCC warnings
      that seem like false-positives to me:
      
      sbbs.h:194:48: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
        194 |                                 (ret)[JSSTSpos]=(char)JSSTSstrval[JSSTSpos]; \
            |                                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      js_file.c:225:25: note: in expansion of macro ‘JSSTRING_TO_STRBUF’
        225 |                         JSSTRING_TO_STRBUF(cx, str, p->mode, sizeof(p->mode), NULL);
            |                         ^~~~~~~~~~~~~~~~~~
      js_file.c:42:17: note: at offset 5 into destination object ‘mode’ of size 5
         42 |         char    mode[5];
            |                 ^~~~
      
      Similar use of JSSTRING_TO_STRBUF in other files (js_console.cpp, js_archive.c)
      (with larger target buffers) does not trigger the same warnings.
      10562789
  8. Aug 08, 2024
    • Rob Swindell's avatar
      Prevent NULL pointer dereference when 'null' object passed to JS functions · 54523145
      Rob Swindell authored
      As was discovered as part of investigation into issue #769, a JavaScript
      could crash SBBS (cause a segfault) due to a NULL pointer dereference when
      the script passes 'null' to native JS functions where an object is expected.
      
      The issue raised was with console.gotoxy(), but it turns out that *many*
      Synchronet native JS functions would call JSVAL_TO_OBJECT() and then, without
      checking for NULL/nullptr, pass its return value to JS api functions such as
      JS_GetPrivate, JS_GetProperty, JS_GetClass, JS_ObjectIsFunction,
      JS_IsArrayObject, JS_GetArrayLength, JS_DefineProperty, JS_Enumerate, etc.
      All of these JS API functions dereference the passed object pointer without
      NULL/nullptr checking.
      
      The fix here is to either call JSVAL_IS_NULL() or JSVAL_NULL_OR_VOID() and
      if true, not call JSVAL_TO_OBJECT() and/or check the return value for the NULL
      value before using as an argument to any other JS API functions.
      54523145
  9. May 25, 2024
  10. Mar 24, 2024
  11. Jan 20, 2024
    • Rob Swindell's avatar
      The great BOOL->bool conversion in xpdev · 118984e9
      Rob Swindell authored
      Still using BOOL where we need Win32 API compatibility.
      Using JSBool instead of BOOL or bool where it matters.
      Changed most relevant TRUE/FALSE to true/false too (though it's not as critical).
      
      You shouldn't need to #include <stdbool.h> anywhere now - gen_defs.h should do that automatically/correctly based on the language/version/tool. In C23, stdbool.h isn't even needed for bool/true/false definitions (they're keywords), so we don't bother including stdbool.h in that case.
      Microsoft didn't define __STDC_VERSION__ in their older tool chains (even though they were C99 compatible and had stdbool.h), so we use a _MSC_VER check to know that there's a stdbool.h we should use in that case.
      
      For other/old compilers (e.g. Borland C) we #define bool/true/false following the pattern of stdbool.h (doesn't use a typedef).
      
      I didn't convert UIFC yet.
      
      This addresses issue #698
      118984e9
  12. Nov 07, 2023
    • Rob Swindell's avatar
      JSDOC build cleanup (used to generate jsobjs.html) · 96019606
      Rob Swindell authored
      Replaced _property_ver_list (array of numbers) with _property_ver_list (array
      of objects) with a "ver" and (optional) "desc" property. This solves the
      enumeration order problem with objects that have both manual and table-based
      properties. Object's property tables (arrays of jsSyncPropertySpec) can now
      (optionally) contain the property descriptions. For properties defined in this
      manner, there will never be another mismatch between ther name/type and
      description/version in the jsobjs.html (a problem has re-occurred several
      times through the years with nebulous work-arounds).
      
      We still use _property_desc_list arrays for additional (e.g. manually defined)
      properties in such objects or just objects that only use one method of
      property definition and are not subject to the enumeration order problem.
      
      Fixed numerous typos.
      
      Using more consistent terminology and HTML mark-up.
      
      Some beautification and enhancement of readability, but nothing too major.
      96019606
  13. Jun 04, 2023
    • Rob Swindell's avatar
      Fix warnings raised by gcc -D_FORTIFY_SOURCE=3 -O1 · 8667e329
      Rob Swindell authored
      A bunch of possible (but often, not really) use of undefined values.
      Some ignored return values (e.g. of chsize/ftruncate, read, write, fgets).
      
      Other than some added diagnostics upon some of these unexpected syscall
      failures, there should be no change in behavior from this commit.
      8667e329
  14. Mar 14, 2023
  15. Jan 17, 2023
  16. Jun 25, 2022
  17. Mar 02, 2022
  18. Jan 02, 2022
  19. Dec 30, 2021
  20. Apr 23, 2021
    • Rob Swindell's avatar
      Use JS_ValueToECMAUint32 for File position, date, and length properties · 370b79dd
      Rob Swindell authored
      This resolves errors when setting these properties to values > 2147483647
      example:
      !JavaScript  /sbbs/exec/load/sauce_lib.js line 69: Error: can't convert
      2430770157 to an integer
      
      That means you can now seek around (set position) within files > 2GB, truncate
      or extend a file > 2GB, or set a file's date to > Jan-19-2038.
      370b79dd
  21. Apr 04, 2021
  22. Mar 30, 2021
    • Deucе's avatar
      Initial poll() work · 0821142a
      Deucе authored
      Still needs updates in services_thread(), CGI stuff in websrvr.c,
      and sbbs_t::external()
      0821142a
  23. Mar 05, 2021
  24. Feb 22, 2021
  25. Feb 15, 2021
  26. Jan 26, 2021
  27. Jan 24, 2021
    • Rob Swindell's avatar
      More support for !include in .ini files · 2ff1a3b5
      Rob Swindell authored
      Some (important) File methods did not support .ini files that used the !include directive because they were using the xpdev iniRead* API (which performs no "pre-processing") instead of xpdev iniGet*.
      
      Impacted methods:
      - iniGetValue()
      - iniGetKeys()
      - iniGetObject()
      
      The other existing ini* methods already worked fine with nested (!include'd) .ini files. It's possible there's a slight performance penalty with the new implementation since the entire .ini file is always read for each operation and previously it was possible that only a few "lines" were read to find the key(s) of interest. However, since .ini files are not typically huge and the iniRead/file-stream method likely read large (e.g. 8-32K) blocks anyway (which is usually the entire .ini file) - I don't actually suspect any observable impact to performance.
      
      This change was needed for the new ctrl/modopts.d support.
      
      Added new method useful for debugging nested .ini files:
      - iniReadAll()
      2ff1a3b5
Loading