Welcome! Log In Create A New Profile

Advanced

[njs] Fixed potential undefined behavior in memcpy().

Dmitry Volyntsev
May 27, 2020 09:40AM
details: https://hg.nginx.org/njs/rev/164801c99e9a
branches:
changeset: 1402:164801c99e9a
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue May 26 19:02:57 2020 +0000
description:
Fixed potential undefined behavior in memcpy().

The issue was introduced in 1d0825906438.

Found with Clang Static Analyzer.

diffstat:

src/njs_array.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)

diffs (20 lines):

diff -r db77713e0536 -r 164801c99e9a src/njs_array.c
--- a/src/njs_array.c Tue May 26 16:35:11 2020 +0000
+++ b/src/njs_array.c Tue May 26 19:02:57 2020 +0000
@@ -3318,11 +3318,13 @@ njs_array_prototype_sort(njs_vm_t *vm, n
return NJS_ERROR;
}

- p = (void *) njs_cpymem(nslots, slots,
- sizeof(njs_array_sort_slot_t) * (p - slots));
-
if (slots != NULL) {
+ p = (void *) njs_cpymem(nslots, slots,
+ sizeof(njs_array_sort_slot_t) * (p - slots));
njs_mp_free(vm->mem_pool, slots);
+
+ } else {
+ p = nslots;
}

slots = nslots;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed potential undefined behavior in memcpy().

Dmitry Volyntsev 244 May 27, 2020 09:40AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 308
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready