[njs] Issues found by Coverity Scan in Regex have been fixed.
Igor Sysoev
igor at sysoev.ru
Thu Mar 24 15:17:04 UTC 2016
details: http://hg.nginx.org/njs/rev/027e0e8e7f61
branches:
changeset: 90:027e0e8e7f61
user: Igor Sysoev <igor at sysoev.ru>
date: Thu Mar 24 14:22:08 2016 +0300
description:
Issues found by Coverity Scan in Regex have been fixed.
diffstat:
njs/njs_regexp.c | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diffs (60 lines):
diff -r 425cf63a7283 -r 027e0e8e7f61 njs/njs_regexp.c
--- a/njs/njs_regexp.c Thu Mar 24 13:57:06 2016 +0300
+++ b/njs/njs_regexp.c Thu Mar 24 14:22:08 2016 +0300
@@ -36,6 +36,8 @@ static int njs_regexp_pattern_compile(pc
u_char *source, int options);
static njs_ret_t njs_regexp_exec_result(njs_vm_t *vm, njs_regexp_t *regexp,
u_char *string, int *captures, nxt_uint_t utf8);
+static njs_ret_t njs_regexp_string_create(njs_vm_t *vm, njs_value_t *value,
+ u_char *start, uint32_t size, int32_t length);
njs_ret_t
@@ -436,7 +438,7 @@ njs_regexp_prototype_source(njs_vm_t *vm
size = strlen((char *) source) - pattern->flags;
length = nxt_utf8_length(source, size);
- return njs_string_create(vm, &vm->retval, source, size, length);
+ return njs_regexp_string_create(vm, &vm->retval, source, size, length);
}
@@ -454,7 +456,7 @@ njs_regexp_prototype_to_string(njs_vm_t
size = strlen((char *) source);
length = nxt_utf8_length(source, size);
- return njs_string_create(vm, &vm->retval, source, size, length);
+ return njs_regexp_string_create(vm, &vm->retval, source, size, length);
}
@@ -621,7 +623,8 @@ njs_regexp_exec_result(njs_vm_t *vm, njs
break;
}
- ret = njs_string_create(vm, &array->start[i], start, size, length);
+ ret = njs_regexp_string_create(vm, &array->start[i],
+ start, size, length);
if (nxt_slow_path(ret != NXT_OK)) {
return NXT_ERROR;
}
@@ -684,6 +687,19 @@ njs_regexp_exec_result(njs_vm_t *vm, njs
}
+static njs_ret_t
+njs_regexp_string_create(njs_vm_t *vm, njs_value_t *value, u_char *start,
+ uint32_t size, int32_t length)
+{
+ if (nxt_fast_path(length >= 0)) {
+ return njs_string_create(vm, value, start, size, length);
+ }
+
+ vm->exception = &njs_exception_internal_error;
+ return NXT_ERROR;
+}
+
+
static const njs_object_prop_t njs_regexp_constructor_properties[] =
{
/* RegExp.name == "RegExp". */
More information about the nginx-devel
mailing list