Skip to content
Snippets Groups Projects
  1. Mar 17, 2021
    • Deucе's avatar
      Close Socket on unhandled TLS errors · ba5759c2
      Deucе authored
      While errors on transmit seem to be handled well, errors on receive
      do not, especially through js_recv_line() which has been seen to
      trigger a large number (hundreds) of ECONNRESET errors.  To prevent
      this, simply close the socket when an otherwise unhandled error
      occurs.
      
      Almost certainly fixes that issue, but the underlying cause is still
      undetermined.  The calling script (imapservice.js) was checking
      Socket.is_connected after each recv_line() call, so if the socket
      was actually reset, it would be expected to only call it once.
      
      An alternative would be to explicitly handle the error that is
      seen (CRYPT_ERROR_PARAM1), but let's try a generic fix first and see
      of anything breaks because of it.  Most likely issue would be an
      inability to recv() data after calling shutdown(), but I don't think
      many people do that except to move the TIME_WAIT to where they want
      it.
      ba5759c2
  2. Feb 22, 2021
  3. Feb 16, 2021
  4. Feb 15, 2021
  5. Nov 26, 2020
    • Rob Swindell's avatar
      Fix bug with Socket.getoption() of byte-sized options · 51e31575
      Rob Swindell authored
      Only observed on Windows, the option value variable (val) was uninitialized so querying byte-sized options using WinSock getsockopt() would leave the MSB of the value as undefined (garbage), resulting in sockinfo.js output like this:
      KEEPALIVE = -858993663
      instead of this:
      KEEPALIVE = 1
      51e31575
  6. Nov 22, 2020
  7. Nov 20, 2020
  8. Nov 19, 2020
  9. Nov 06, 2020
    • Rob Swindell's avatar
      Replace ctype.h function calls with new MSVC-safe XPDEV macros · ec20d959
      Rob Swindell authored
      I'm fed-up with MSVC assertions in ctype functions (e.g. isdigit, isprint, isspace, etc.) when called with out-of-range (e.g. negative) values.
      
      This problem only affects MSVC debug builds, but if you run them (like I do), these things are like little time bombs that can drive you crazy (knocking your board out of service).
      
      The new macros names are bit more descriptive as well.
      ec20d959
  10. Sep 25, 2020
  11. Aug 16, 2020
  12. Aug 09, 2020
  13. Apr 09, 2020
  14. Sep 17, 2019
  15. Sep 09, 2019
    • deuce's avatar
      Revision 1.242 prevented do_js_close() from being called in the finalize · 3e073461
      deuce authored
      function for external sockets.  However, service thrads that use TLS were
      relying on the finalize function to clean up the TLS session.
      
      Revert 1.242, and add a finalize parameter to do_js_close() which will only
      avoid the shutdown() call rather than completely avoid do_js_close()
      completely.
      
      This fixes a TLS session leak that would eventually prevent any new
      encrypted connections.
      3e073461
  16. Aug 27, 2019
  17. Aug 21, 2019
  18. Aug 17, 2019
  19. Aug 15, 2019
  20. Aug 06, 2019
  21. Aug 05, 2019
  22. Aug 04, 2019
  23. Jun 21, 2019
    • deuce's avatar
      Fix handling of responses with no content. · b311c1c3
      deuce authored
      This introduces a new request field send_content which indicates if the
      content should be sent.  This covers various cases like HEAD responses
      where there's an entity, but no content is sent as well as 204, 304, and 1xx
      responses where there is not even an entity.
      
      writebuf() will now enforce this, so there's no need for various checks
      throughout the code to see if data should be sent or not.
      
      Also, we now only set sent_headers after the headers are sent.
      b311c1c3
  24. May 04, 2019
    • rswindell's avatar
    • rswindell's avatar
      Define and use a wrapper for JS_GetInstancePrivate(): js_GetClassPrivate() · 6f83c4ff
      rswindell authored
      Use this in place of JS_GetPrivate() in native class methods that need the
      class instance's private data pointer and will do bad things if that pointer
      points to something other than what is expected. mcmlxxix (matt) discovered
      that using Object.apply(), you can invoke class methods where the 'this'
      instance is a different class. This would result in
      "Internal Error: No Private Data." or a crash.
      So now, gracefully detect this condition and report a meaningful error:
      "'<class-name>' instance: No Private Data or Class Mismatch"
      
      Also, important to note: if the method uses JS_THIS_OBJECT to get the JSObject*
      to pass to JS_Get*Private, then it must do this *before* it calls JS_SET_RVAL.
      
      From jsapi.h:
       * NB: there is an anti-dependency between JS_CALLEE and JS_SET_RVAL: native
       * methods that may inspect their callee must defer setting their return value
       * until after any such possible inspection. Otherwise the return value will be
       * inspected instead of the callee function object.
      
      The js_crypt*.c files still need this treatment.
      6f83c4ff
  25. Mar 07, 2019
    • deuce's avatar
      There appears to be data corruption in cryptlib if a private key is added · 211a2a1a
      deuce authored
      to a second thread before the first has the session set active.  Add calls
      to lock/unlock the certificate to prevent this.
      
      The better options is likely to have a function that adds the key and socket
      and sets the session active in one call and handles the locking internally.
      
      But I'm lazy, so we get the lock functions.
      211a2a1a
  26. Jan 12, 2019
    • rswindell's avatar
      Bug-fix: Socket.connect() would return true (success) even though a · 7685c9d7
      rswindell authored
      TCP connection actually failed. This bug only appeared to affect *nix
      systems. This bug appears to be very old, introduced in rev 1.74 of
      this file (Mar-2003) by yours truly.
      From the Linux 'connect' man page:
      EINPROGRESS
                    The  socket  is  nonblocking  and the connection cannot be i
                    completed immediately.  It is possible to select(2) or poll(2)
                    for completion by selecting the socket for writing.  After
                    select(2) indicates writability, use getsockopt(2) to read the
                    SO_ERROR option at level SOL_SOCKET to determine whether
                    connect() completed successfully (SO_ERROR is zero) or
                    unsuccessfully (SO_ERROR is one of the usual error codes listed
                    here, explaining the reason for the failure).
      
      We weren't doing the 'getsockopt(SO_ERROR)' part.
      7685c9d7
Loading