]> git.kaiwu.me - njs.git/log
njs.git
3 years agoVersion 0.7.4. 0.7.4
Dmitry Volyntsev [Tue, 24 May 2022 16:07:58 +0000 (09:07 -0700)]
Version 0.7.4.

3 years agoTests: adapted WebCrypto tests to RHEL9.
Dmitry Volyntsev [Tue, 24 May 2022 05:26:51 +0000 (22:26 -0700)]
Tests: adapted WebCrypto tests to RHEL9.

3 years agoFixed use-of-uninitialized-value introduced in beb180165976.
Dmitry Volyntsev [Tue, 24 May 2022 05:26:50 +0000 (22:26 -0700)]
Fixed use-of-uninitialized-value introduced in beb180165976.

Found by Memory Sanitizer.

3 years agoFixed Object.prototype.constructor property handler with large heap.
Dmitry Volyntsev [Tue, 24 May 2022 05:26:35 +0000 (22:26 -0700)]
Fixed Object.prototype.constructor property handler with large heap.

Found by Memory Sanitizer.

3 years agoFixed redefinition of special props in Object.defineProperty().
Dmitry Volyntsev [Thu, 19 May 2022 23:41:08 +0000 (16:41 -0700)]
Fixed redefinition of special props in Object.defineProperty().

Previously, when NJS_PROPERTY_HANDLER property was updated it might be
left in inconsistent state.  Namely, prop->type was left unchanged, but
prop->value did not have an expected property handler.  As a result
consecutive reference to the property may result in a segment violation.

The fix is to update the prop->type during redefinition.

This closes #504 issue on Github.

3 years agoGetting rid of excessive NJS_LEVEL_TEMP.
Dmitry Volyntsev [Wed, 18 May 2022 07:01:05 +0000 (00:01 -0700)]
Getting rid of excessive NJS_LEVEL_TEMP.

3 years agoAdded generator debug.
Dmitry Volyntsev [Wed, 18 May 2022 06:26:09 +0000 (23:26 -0700)]
Added generator debug.

3 years agoImproved OPCODE debug.
Dmitry Volyntsev [Wed, 18 May 2022 06:26:05 +0000 (23:26 -0700)]
Improved OPCODE debug.

3 years agoFixed compatibility with BoringSSL.
Dmitry Volyntsev [Tue, 17 May 2022 05:57:27 +0000 (22:57 -0700)]
Fixed compatibility with BoringSSL.

The fix is to use more conventional API when dealing with HMAC
algorithm.

This closes #455 issue on Github.

4 years agoMaking function expression binding immutable according the specs.
Dmitry Volyntsev [Thu, 12 May 2022 04:08:21 +0000 (21:08 -0700)]
Making function expression binding immutable according the specs.

This closes #56 issue on Github.

4 years agoLeaving consistency checks as asserts for njs_scope_index().
Dmitry Volyntsev [Thu, 12 May 2022 00:51:17 +0000 (17:51 -0700)]
Leaving consistency checks as asserts for njs_scope_index().

4 years agoFixed ellipsis support.
Dmitry Volyntsev [Wed, 11 May 2022 23:33:46 +0000 (16:33 -0700)]
Fixed ellipsis support.

As of now, ellispis syntax is supported for function declaration with
the rest arguments.

This closes #365 issue on Github.

4 years agoFixed Array.prototype.fill() for typed-arrays.
Dmitry Volyntsev [Sat, 7 May 2022 01:55:35 +0000 (18:55 -0700)]
Fixed Array.prototype.fill() for typed-arrays.

This closes #478 issue on Github.

4 years agoFixed Object.defineProperty() when a recursive descriptor is provided.
Dmitry Volyntsev [Sat, 7 May 2022 01:55:07 +0000 (18:55 -0700)]
Fixed Object.defineProperty() when a recursive descriptor is provided.

This closes #481 issue on Github.

4 years agoImproved surrogate pairs support for PCRE2 backend.
Dmitry Volyntsev [Fri, 6 May 2022 03:25:05 +0000 (20:25 -0700)]
Improved surrogate pairs support for PCRE2 backend.

In collaboration with Javier Evans.

4 years agoFixed JSON.parse() when reviver function is provided.
Dmitry Volyntsev [Wed, 4 May 2022 23:44:48 +0000 (16:44 -0700)]
Fixed JSON.parse() when reviver function is provided.

This closes #480 issue on Github.

4 years agoImplement OrdinaryDelete() which does not throw exception.
Dmitry Volyntsev [Wed, 4 May 2022 23:23:46 +0000 (16:23 -0700)]
Implement OrdinaryDelete() which does not throw exception.

4 years agoAdded njs.version_number property.
Dmitry Volyntsev [Fri, 29 Apr 2022 00:59:03 +0000 (17:59 -0700)]
Added njs.version_number property.

4 years agoOptimising JSON.parse() for large objects.
Dmitry Volyntsev [Fri, 29 Apr 2022 00:49:59 +0000 (17:49 -0700)]
Optimising JSON.parse() for large objects.

4 years agoHTTP: expect escaped URIs in r.internalRedirect().
Dmitry Volyntsev [Fri, 29 Apr 2022 00:23:02 +0000 (17:23 -0700)]
HTTP: expect escaped URIs in r.internalRedirect().

Similarly to the nginx change in 975d7ab37b39 (1.17.2), we should accept
properly escaped URIs and unescape them as needed, else it is not possible
to handle URIs with question marks.

Previously, the URI was used as is.

4 years agoModules: added additional directives for Fetch API.
Dmitry Volyntsev [Thu, 28 Apr 2022 23:37:14 +0000 (16:37 -0700)]
Modules: added additional directives for Fetch API.

The following directives are added:
    * js_fetch_timeout
    * js_fetch_verify
    * js_fetch_buffer_size
    * js_fetch_max_response_buffer_size

This closes #489 issue on Github.

4 years agoFixed Array.prototype.lastIndexOf() with unicode string as "this".
Dmitry Volyntsev [Wed, 27 Apr 2022 23:31:00 +0000 (16:31 -0700)]
Fixed Array.prototype.lastIndexOf() with unicode string as "this".

Previously, when lastIndexOf() was called with unicode string as "this"
argument and a negative "fromIndex" argument null-pointer dererence
might occur because njs_string_offset() was called with invalid index
value whereas njs_string_offset() should always be called with valid
index argument.

The fix is to verify that from index is valid.

This closes #482 issue on Github.

4 years agoMaking FOREACH and NEXT instructions robust to invalid input.
Dmitry Volyntsev [Tue, 26 Apr 2022 23:07:06 +0000 (16:07 -0700)]
Making FOREACH and NEXT instructions robust to invalid input.

4 years agoFixed aggregation methods of Promise ctor with array-like object.
Dmitry Volyntsev [Tue, 26 Apr 2022 23:07:02 +0000 (16:07 -0700)]
Fixed aggregation methods of Promise ctor with array-like object.

Previously, while iterating over an array-like object the methods may be
resolved with INVALID values. INVALID value is a special internal type which
should never be visible by ordinary functions.

The fix is to ensure that absent elements are represented by undefined value.

The following methods were fixed Promise.all(), Promise.allSettled(),
    Promise.any(), Promise.race().

This closes #483 issue on Github.

4 years agoFixed Array.prototype.slice() with slow "this" argument.
Dmitry Volyntsev [Sat, 23 Apr 2022 00:02:36 +0000 (17:02 -0700)]
Fixed Array.prototype.slice() with slow "this" argument.

Previously, when "this" argument was not a fast array, but the "deleted" array
was a fast array, the "deleted" array may be left in uninitialized state if
"this" argument had gaps.

This fix is to ensure that "deleted" is properly initialized.

This fixes #485 issue on Github.

4 years agoFixed Array.prototype.sort() when arr size is changed in a comparator.
Dmitry Volyntsev [Sat, 23 Apr 2022 00:02:28 +0000 (17:02 -0700)]
Fixed Array.prototype.sort() when arr size is changed in a comparator.

This fixed #468 issue on Github.

4 years agoFixed Response headers iteration in Fetch API.
Dmitry Volyntsev [Thu, 14 Apr 2022 23:07:34 +0000 (16:07 -0700)]
Fixed Response headers iteration in Fetch API.

Previously, heap-use-after-free might occur when HTTP Response was
received with more than 8 headers and headers iteration is used.

The fix is not to assume that pointer to the beginning of the keys array
never changes.  The pointer may change when array is resized.

The issue was introduced in 81040de6b085 (0.5.1).

This closes #492 issue on Github.

4 years agoVersion bump
Dmitry Volyntsev [Thu, 14 Apr 2022 22:39:15 +0000 (15:39 -0700)]
Version bump

4 years agoAdded tag 0.7.3 for changeset f15d039cf625
Dmitry Volyntsev [Tue, 12 Apr 2022 04:26:35 +0000 (21:26 -0700)]
Added tag 0.7.3 for changeset f15d039cf625

4 years agoVersion 0.7.3. 0.7.3
Dmitry Volyntsev [Tue, 12 Apr 2022 04:22:32 +0000 (21:22 -0700)]
Version 0.7.3.

4 years agoFixed typo while calculating module path length.
Dmitry Volyntsev [Mon, 11 Apr 2022 22:55:14 +0000 (15:55 -0700)]
Fixed typo while calculating module path length.

The issue was introduced in 77c398f26d7e (not released yet).

4 years agoFixed njs_vmcode_interpreter() when "toString" conversion fails.
Dmitry Volyntsev [Mon, 28 Mar 2022 16:22:17 +0000 (16:22 +0000)]
Fixed njs_vmcode_interpreter() when "toString" conversion fails.

Previously, while interpreting a user function, njs_vmcode_interpreter()
might return prematurely when an error happens.  This is not correct
because the current frame has to be unwound (or exception caught)
first.

The fix is exit through only 5 appropriate exit points to ensure
proper unwinding.

This closes #467 issue on Github.

4 years agoTests: introduced OPCODE debug.
Dmitry Volyntsev [Tue, 22 Feb 2022 19:38:59 +0000 (19:38 +0000)]
Tests: introduced OPCODE debug.

4 years agoFixed allocation of large array literals.
Dmitry Volyntsev [Mon, 21 Feb 2022 16:53:16 +0000 (16:53 +0000)]
Fixed allocation of large array literals.

Previously, allocation of large array literals may result in
null-pointer dereference. The reason is that njs_array_alloc() may
return a slow array when size is large enough, but the instruction
code assumes that array is always flat.

The fix is to check fast_array flag before accessing array->start.

This closes #473 issue on Github.

4 years agoFixed frame allocation from an awaited frame.
Dmitry Volyntsev [Mon, 21 Feb 2022 16:52:59 +0000 (16:52 +0000)]
Fixed frame allocation from an awaited frame.

njs_function_frame_save() is used to save the awaited frame when "await"
instruction is encountered. The saving was done as a memcpy() of
existing runtime frame.

njs_function_frame_alloc() is used to alloc a new function frame, this
function tries to use a spare preallocated memory from the previous
frame first.  Previously, this function might result in "use-after-free"
when invoked from a restored frame saved with njs_function_frame_save().
Because njs_function_frame_save() left pointers to the spare memory of
the original frame which may be already free when saved frame is
restored.

The fix is to erase fields for the spare memory from the saved frame.

This closes #469 issue on Github.

4 years agoFixed Array.prototype.concat() when "this" is a slow array.
Dmitry Volyntsev [Mon, 21 Feb 2022 16:52:47 +0000 (16:52 +0000)]
Fixed Array.prototype.concat() when "this" is a slow array.

Previously, when the current appended element is fast array the "this"
array was expected to always be a fast array also.  This may not be the
case when the previous appended element was not fast thus converting
the "this" array to a slow form.

Previous fix introduced in 2c1382bab643 (0.7.2) was not complete, the
correct fix is to never assume "this" is fast, whereas njs_array_add()
may only be called with fast arrays.

This closes #471 issue in Github.

4 years agoRefactoring of user modules importing.
Dmitry Volyntsev [Mon, 21 Feb 2022 14:49:38 +0000 (14:49 +0000)]
Refactoring of user modules importing.

Previously, user modules were compiled as as anonymous functions in a
global scope.  This is incorrect, because modules should be compiled
in their own scope.

In addition, this patch introduces HostResolveImportedModule support.
When vm->options.ops->module_loader is provided, a module lookup
and compilation is delegated to this callback.

This closes #443 issue on Github.

4 years agoTests: splitting large import tests into several simple ones.
Dmitry Volyntsev [Tue, 15 Feb 2022 13:17:52 +0000 (13:17 +0000)]
Tests: splitting large import tests into several simple ones.

4 years agoIntroduced njs_parser_init().
Dmitry Volyntsev [Mon, 14 Feb 2022 14:10:59 +0000 (14:10 +0000)]
Introduced njs_parser_init().

4 years agoFixed Function constructor in CLI.
Dmitry Volyntsev [Mon, 14 Feb 2022 14:10:47 +0000 (14:10 +0000)]
Fixed Function constructor in CLI.

Previously, Function constructor exported its local variables to
vm->variables_hash. vm->variables_hash is used in njs CLI to query
global variables during console input completion.  The exporting is
incorrect because it pollutes the global scope.

4 years agoFixed backtraces for native modules imported with import statement.
Dmitry Volyntsev [Mon, 14 Feb 2022 14:10:26 +0000 (14:10 +0000)]
Fixed backtraces for native modules imported with import statement.

Previously, the module name was missing when exception is reported
for a native module function imported with import statement.

4 years agoFixed backtraces while traversing imported user modules.
Dmitry Volyntsev [Mon, 14 Feb 2022 14:10:04 +0000 (14:10 +0000)]
Fixed backtraces while traversing imported user modules.

Previously, njs_builtin_match_native_function(), which is used to build a
backtrace for an exception, assumed that user modules always return
object values, which is not the case.  As a result, njs_object_traverse()
may receive incorrect pointer.

This fix is to only traverse object values.

4 years agoTests: refactored modules tests using test262 test suite.
Dmitry Volyntsev [Thu, 27 Jan 2022 13:01:55 +0000 (13:01 +0000)]
Tests: refactored modules tests using test262 test suite.

4 years agoTests: added support for proper negative test262 tests.
Dmitry Volyntsev [Wed, 26 Jan 2022 17:24:58 +0000 (17:24 +0000)]
Tests: added support for proper negative test262 tests.

4 years agoTypes: added async/await support for TS files.
Jakub Jirutka [Wed, 26 Jan 2022 01:44:18 +0000 (02:44 +0100)]
Types: added async/await support for TS files.

Since 0.7.0 async/await support was added.

This closes #461 issue on Github.

4 years agoShell: added options for custom exit failure code.
Dmitry Volyntsev [Wed, 26 Jan 2022 17:24:57 +0000 (17:24 +0000)]
Shell: added options for custom exit failure code.

4 years agoVersion bump.
Dmitry Volyntsev [Tue, 25 Jan 2022 19:06:58 +0000 (19:06 +0000)]
Version bump.

4 years agoAdded tag 0.7.2 for changeset 3dd315b80bab
Dmitry Volyntsev [Tue, 25 Jan 2022 13:38:25 +0000 (13:38 +0000)]
Added tag 0.7.2 for changeset 3dd315b80bab

4 years agoVersion 0.7.2. 0.7.2
Dmitry Volyntsev [Tue, 25 Jan 2022 13:37:45 +0000 (13:37 +0000)]
Version 0.7.2.

4 years agoFixed function redeclaration.
Dmitry Volyntsev [Tue, 25 Jan 2022 13:18:20 +0000 (13:18 +0000)]
Fixed function redeclaration.

Previously, the existing lambda structure was reused resulting in the
properties of the previously defined function was merged into a new one.

The bug was introduced in 66bd2cc7fd87 (0.7.0).

4 years agoFixed recursive async function calls.
Dmitry Volyntsev [Fri, 21 Jan 2022 14:31:30 +0000 (14:31 +0000)]
Fixed recursive async function calls.

Previously, PromiseCapability record was stored (function->context)
directly in function object during a function invocation.  This is
not correct, because PromiseCapability record should be linked to
current execution context.  As a result, function->context is
overwritten with consecutive recursive calls which results in
use-after-free.

This closes #451 issue on Github.

4 years agoFixed Function.prototype.apply() with slow arrays.
Dmitry Volyntsev [Wed, 19 Jan 2022 14:03:49 +0000 (14:03 +0000)]
Fixed Function.prototype.apply() with slow arrays.

Previously, the function had two issues:
   * array->start was referenced without checking for fast array flag
   * the created arguments list was not sanity-checked for its length,
     which can be very large.

The fix is to remove micro-optimization for arrays and introduce limit
size for arguments list.

This closes #449 issue in Github.

4 years agoFixed type confusion bug while resolving promises.
Dmitry Volyntsev [Wed, 19 Jan 2022 13:12:09 +0000 (13:12 +0000)]
Fixed type confusion bug while resolving promises.

Previously, the internal function njs_promise_perform_then() which
implements PerformPromiseThen() expects its first argument to always be
a promise instance.  This assertion might be invalid because the
functions corresponding to Promise.prototype.then() and
Promise.resolve() incorrectly verified their arguments.

Specifically, the functions recognized their first argument as promise
if it was an object which was an Promise or had Promise object in its
prototype chain.  The later condition is not correct because internal
slots are not inherited according to the spec.

This closes #447 issue in Github.

4 years agoImproved access to this argument.
Dmitry Volyntsev [Tue, 18 Jan 2022 15:37:11 +0000 (15:37 +0000)]
Improved access to this argument.

'this' argument is always present, so it may be accessed
without checking the number provided arguments.

4 years agoFixed Buffer.concat() with subarrays.
Sylvain Etienne [Tue, 18 Jan 2022 07:37:09 +0000 (08:37 +0100)]
Fixed Buffer.concat() with subarrays.

This closes #458 issue on Github.

4 years ago2022 year.
Dmitry Volyntsev [Tue, 18 Jan 2022 15:36:40 +0000 (15:36 +0000)]
2022 year.

4 years agoFixed Array.prototype.concat() with exotic argument object.
Dmitry Volyntsev [Tue, 18 Jan 2022 15:35:00 +0000 (15:35 +0000)]
Fixed Array.prototype.concat() with exotic argument object.

The issue was introduced in 2c1382bab643.

4 years agoFixed Array.prototype.reverse() when array is changed while iterating.
Dmitry Volyntsev [Fri, 14 Jan 2022 14:40:27 +0000 (14:40 +0000)]
Fixed Array.prototype.reverse() when array is changed while iterating.

Previously, the flat array may be converted to a slow one as a
side-effect of a custom getter invocation for a proto array object.
The function erroneously assumed that the this array remains flat
while iterating.

The fix is to eliminate the micro-optimization which uses direct
pointers.

The problem is similar to the previous commits.

4 years agoSimplified element access in Array.prototype.shift().
Dmitry Volyntsev [Thu, 13 Jan 2022 18:30:31 +0000 (18:30 +0000)]
Simplified element access in Array.prototype.shift().

Previously, array structure may be left in inconsistent state
when a custom getter in a proto array changes array size.

The change is similar to the previous commits.

4 years agoSimplified element access in Array.prototype.pop().
Dmitry Volyntsev [Thu, 13 Jan 2022 18:30:31 +0000 (18:30 +0000)]
Simplified element access in Array.prototype.pop().

The change is similar to the previous commits.

4 years agoFixed Array.prototype.concat() when array is changed while iterating.
Dmitry Volyntsev [Thu, 13 Jan 2022 16:20:58 +0000 (16:20 +0000)]
Fixed Array.prototype.concat() when array is changed while iterating.

Previously, the flat array may be converted to a slow one as a
side-effect of a custom getter invocation for a proto array object.
The function erroneously assumed that the this array remains flat
while iterating.

The fix is to eliminate the micro-optimization which uses direct
pointers.

The problem is similar to the previous commits.

4 years agoFixed Array.prototype.slice() when array is changed while iterating.
Dmitry Volyntsev [Thu, 13 Jan 2022 15:59:08 +0000 (15:59 +0000)]
Fixed Array.prototype.slice() when array is changed while iterating.

Previously, the flat array may be converted to a slow one as a
side-effect of a custom getter invocation for a proto array object.
The function erroneously assumed that the this array remains flat
while iterating.

The fix is to eliminate the micro-optimization which uses direct
pointers.

The problem is similar to the previous (9578cc729205) commit.

This closes #445 issue on Github.

4 years agoFixed Array.prototype.join() when array is changed while iterating.
Dmitry Volyntsev [Wed, 12 Jan 2022 17:59:42 +0000 (17:59 +0000)]
Fixed Array.prototype.join() when array is changed while iterating.

Previously, the function used optimization for ordinary arrays with no
gaps (so called fast arrays).  For a fast array code took elements
directly from internal flat C array. The direct pointer may become
invalid as side-effect of custom toString() method for an element.

Specifically, the pointer was passed directly to
njs_value_to_primitive() which attempts to call toString() followed by
valueOf().  When the array size is changed as a side-effect of
toString() and not a string value is returned by toString() the pointer
becomes invalid and is passed to valueOf() which causes use-after-free.

The fix is to eliminate the micro-optimization which uses direct pointers.

Found by PolyGlot fuzzing framework.

This closes #444 issue on Github.

4 years agoMaking njs_value_property_i64() and njs_value_property_i64_set() fast.
Dmitry Volyntsev [Wed, 12 Jan 2022 17:58:19 +0000 (17:58 +0000)]
Making njs_value_property_i64() and njs_value_property_i64_set() fast.

Since f5afb325896f (0.3.9) njs_value_property() and
njs_value_property_set() have fast paths when key is a number.

Passing key as a number eliminates conversion index to string and back.

4 years agoRemoving MSAN unpoison workarounds for clang-9 and below.
Dmitry Volyntsev [Wed, 12 Jan 2022 17:58:18 +0000 (17:58 +0000)]
Removing MSAN unpoison workarounds for clang-9 and below.

MSAN unpoison workaround was introduced in 13dbdff9b76f (0.3.9) for a
false-positive bug in clang-9 and below.

Also, after 80d95b2881f6 (0.4.1) the bug is not triggered anymore.

4 years agoFixed fuzzing target bug introduced in 4d4657128baf (0.7.1).
Dmitry Volyntsev [Tue, 11 Jan 2022 13:02:33 +0000 (13:02 +0000)]
Fixed fuzzing target bug introduced in 4d4657128baf (0.7.1).

Previously, njs_process_script() took vm pointer from console object,
but after 4d4657128baf the object is not initialized in
LLVMFuzzerTestOneInput().

The fix is to always pass vm pointer explicitly.

This also closes #456 issue on Github.

4 years agoImproved discovery of OpenSSL libraries.
Dmitry Volyntsev [Wed, 29 Dec 2021 18:26:40 +0000 (18:26 +0000)]
Improved discovery of OpenSSL libraries.

Trying to link again the library using --cc-opt and --ld-opt before
attempting to use the default.

This change is similar to 9e2e4d04dfc4 (0.7.1) made for PCRE.

4 years agoConfigure: added --build-dir option.
Dmitry Volyntsev [Wed, 29 Dec 2021 17:20:09 +0000 (17:20 +0000)]
Configure: added --build-dir option.

4 years agoTests: fixed "fs" tests with custom build directory.
Dmitry Volyntsev [Wed, 29 Dec 2021 17:19:55 +0000 (17:19 +0000)]
Tests: fixed "fs" tests with custom build directory.

4 years agoConfigure: fixed custom NJS_BUILD_DIR values support.
Dmitry Volyntsev [Wed, 29 Dec 2021 16:56:47 +0000 (16:56 +0000)]
Configure: fixed custom NJS_BUILD_DIR values support.

The issue was introduced in 4d4657128baf (0.7.1).

This closes #454 issue on Github.

4 years agoAdded description for recently added configure options.
Dmitry Volyntsev [Wed, 29 Dec 2021 16:03:13 +0000 (16:03 +0000)]
Added description for recently added configure options.

4 years agoTypes: added TS definitions for fs.stat() and fs.lstat() methods.
Dmitry Volyntsev [Wed, 29 Dec 2021 16:03:12 +0000 (16:03 +0000)]
Types: added TS definitions for fs.stat() and fs.lstat() methods.

4 years agoVersion bump.
Dmitry Volyntsev [Wed, 29 Dec 2021 16:03:11 +0000 (16:03 +0000)]
Version bump.

4 years agoAdded tag 0.7.1 for changeset 35aca5cc5ea7
Dmitry Volyntsev [Tue, 28 Dec 2021 14:24:53 +0000 (14:24 +0000)]
Added tag 0.7.1 for changeset 35aca5cc5ea7

4 years agoVersion 0.7.1. 0.7.1
Dmitry Volyntsev [Tue, 28 Dec 2021 13:55:44 +0000 (13:55 +0000)]
Version 0.7.1.

4 years agoFixed information leak in Buffer.from().
Artem S. Povalyukhin [Sat, 25 Dec 2021 19:45:30 +0000 (22:45 +0300)]
Fixed information leak in Buffer.from().

This closes #446 on Github.

4 years agoImproved Buffer.from() with Buffer-like objects.
Artem S. Povalyukhin [Sat, 25 Dec 2021 19:45:30 +0000 (22:45 +0300)]
Improved Buffer.from() with Buffer-like objects.

4 years agoAdded missing element in typeof table for DataView() type.
Artem S. Povalyukhin [Fri, 24 Dec 2021 07:00:15 +0000 (10:00 +0300)]
Added missing element in typeof table for DataView() type.

Previously, typeof operation for DataView object resulted
in out of bounds array accessing.

This fixes #450 issue on Github.

4 years agoImproved discovery of PCRE libraries.
Dmitry Volyntsev [Fri, 24 Dec 2021 16:54:12 +0000 (16:54 +0000)]
Improved discovery of PCRE libraries.

Trying to link again the library using --cc-opt and --ld-opt before
attempting to use pcre-config or pcre2-config.

4 years agoPassing --ld-opt flags while linking.
Dmitry Volyntsev [Fri, 24 Dec 2021 15:48:12 +0000 (15:48 +0000)]
Passing --ld-opt flags while linking.

4 years agoBuilding regexp backend as an external.
Dmitry Volyntsev [Fri, 24 Dec 2021 15:48:11 +0000 (15:48 +0000)]
Building regexp backend as an external.

This allows not to build PCRE specific code as a part of libnjs.a thus
supporting nginx builds with flags like --with-pcre=PCRE_DIR.  When
--no-pcre configure option is provided external code have to implement
methods declared in njs_regex.h.

This also closes #18 issue on Github.

4 years agoAdding module suffix for njs module files.
Dmitry Volyntsev [Fri, 24 Dec 2021 15:48:09 +0000 (15:48 +0000)]
Adding module suffix for njs module files.

4 years agoIntroducing --no-openssl to disable OpenSSL discover.
Dmitry Volyntsev [Fri, 24 Dec 2021 15:48:09 +0000 (15:48 +0000)]
Introducing --no-openssl to disable OpenSSL discover.

4 years agoTests: added help info for test262.
Dmitry Volyntsev [Fri, 24 Dec 2021 15:48:08 +0000 (15:48 +0000)]
Tests: added help info for test262.

4 years agoFixed 1-byte memory over-read introduced in previous commit.
Dmitry Volyntsev [Thu, 23 Dec 2021 14:28:12 +0000 (14:28 +0000)]
Fixed 1-byte memory over-read introduced in previous commit.

sizeof("\0") returns 2 because of the implicit zero byte added at
the end of string literals. Instead njs_length() was intended to be
used.

4 years agoImproved njs_ftw().
Dmitry Volyntsev [Thu, 23 Dec 2021 13:30:44 +0000 (13:30 +0000)]
Improved njs_ftw().

Replacing strcpy() with memcpy() as the former is considered
insecure.

Found by Clang static analyzer.

4 years agoTests: fixed fs/methods.t.ts on RHEL8.
Dmitry Volyntsev [Wed, 22 Dec 2021 17:22:14 +0000 (17:22 +0000)]
Tests: fixed fs/methods.t.ts on RHEL8.

4 years agoTests: improved test262 output when a test fails.
Dmitry Volyntsev [Wed, 22 Dec 2021 16:54:27 +0000 (16:54 +0000)]
Tests: improved test262 output when a test fails.

4 years agoFixed WebCrypto sign() and verify() methods with OpenSSL 3.0.1.
Dmitry Volyntsev [Wed, 22 Dec 2021 16:54:13 +0000 (16:54 +0000)]
Fixed WebCrypto sign() and verify() methods with OpenSSL 3.0.1.

Since 3.0.1 EVP_DigestSignFinal() expects siglen to contain the
actual buffer size for signature buffer.

4 years agoAdded missed njs_parser_failed() in njs_parser_module_lambda_after().
Zhidao HONG [Wed, 22 Dec 2021 02:50:16 +0000 (10:50 +0800)]
Added missed njs_parser_failed() in njs_parser_module_lambda_after().

4 years agoAdded missed static declarations.
Zhidao HONG [Wed, 22 Dec 2021 02:50:16 +0000 (10:50 +0800)]
Added missed static declarations.

4 years agoFixed OpenSSL detection support when Address Sanitizer is enabled.
Dmitry Volyntsev [Wed, 22 Dec 2021 16:54:05 +0000 (16:54 +0000)]
Fixed OpenSSL detection support when Address Sanitizer is enabled.

4 years agoRefactor modules using external prototypes.
Dmitry Volyntsev [Tue, 21 Dec 2021 17:42:26 +0000 (17:42 +0000)]
Refactor modules using external prototypes.

4 years agoRenaming njs_module_t -> njs_mod_t.
Dmitry Volyntsev [Tue, 21 Dec 2021 15:49:21 +0000 (15:49 +0000)]
Renaming njs_module_t -> njs_mod_t.

4 years agoTests: moving module tests into separate test suites.
Dmitry Volyntsev [Tue, 21 Dec 2021 15:49:13 +0000 (15:49 +0000)]
Tests: moving module tests into separate test suites.

4 years agoTests: moving backtraces test into a separate test suite.
Dmitry Volyntsev [Tue, 21 Dec 2021 15:49:05 +0000 (15:49 +0000)]
Tests: moving backtraces test into a separate test suite.

4 years agoAdded constructor flag for methods in external prototypes.
Dmitry Volyntsev [Tue, 21 Dec 2021 15:48:45 +0000 (15:48 +0000)]
Added constructor flag for methods in external prototypes.

4 years agoModules: removed dead code left after dfcbfb5e27b2.
Dmitry Volyntsev [Tue, 14 Dec 2021 20:14:23 +0000 (20:14 +0000)]
Modules: removed dead code left after dfcbfb5e27b2.

Found by Coverity (CID 1495259).

4 years agoChecking cwd path length in njs_module_relative_path().
Dmitry Volyntsev [Tue, 14 Dec 2021 20:06:23 +0000 (20:06 +0000)]
Checking cwd path length in njs_module_relative_path().

4 years agoUsing njs_arr_item() when accessing vm->protos elements.
Dmitry Volyntsev [Tue, 14 Dec 2021 14:08:12 +0000 (14:08 +0000)]
Using njs_arr_item() when accessing vm->protos elements.