[njs] Segfaults in Date have been fixed.

Igor Sysoev igor at sysoev.ru
Tue Oct 11 14:52:02 UTC 2016


details:   http://hg.nginx.org/njs/rev/40a753cefac1
branches:  
changeset: 193:40a753cefac1
user:      Igor Sysoev <igor at sysoev.ru>
date:      Tue Oct 11 13:01:41 2016 +0300
description:
Segfaults in Date have been fixed.

diffstat:

 njs/njs_date.c           |  2 ++
 njs/test/njs_unit_test.c |  6 ++++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diffs (35 lines):

diff -r aa8137bb7838 -r 40a753cefac1 njs/njs_date.c
--- a/njs/njs_date.c	Mon Oct 10 17:22:26 2016 +0300
+++ b/njs/njs_date.c	Tue Oct 11 13:01:41 2016 +0300
@@ -108,6 +108,7 @@ njs_date_constructor(njs_vm_t *vm, njs_v
 
             for (i = 1; i < n; i++) {
                 if (!njs_is_numeric(&args[i])) {
+                    vm->frame->trap_scratch.data.u.value = &args[i];
                     return NJS_TRAP_NUMBER_ARG;
                 }
 
@@ -186,6 +187,7 @@ njs_date_utc(njs_vm_t *vm, njs_value_t *
 
         for (i = 1; i < n; i++) {
             if (!njs_is_numeric(&args[i])) {
+                vm->frame->trap_scratch.data.u.value = &args[i];
                 return NJS_TRAP_NUMBER_ARG;
             }
 
diff -r aa8137bb7838 -r 40a753cefac1 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c	Mon Oct 10 17:22:26 2016 +0300
+++ b/njs/test/njs_unit_test.c	Tue Oct 11 13:01:41 2016 +0300
@@ -5030,6 +5030,12 @@ static njs_unit_test_t  njs_test[] =
     { nxt_string("var d = new Date(); d.__proto__ === Date.prototype"),
       nxt_string("true") },
 
+    { nxt_string("new Date(eval)"),
+      nxt_string("Invalid Date") },
+
+    { nxt_string("Date.UTC(eval)"),
+      nxt_string("NaN") },
+
     { nxt_string("Date.name"),
       nxt_string("Date") },
 



More information about the nginx-devel mailing list