[njs] Avoiding casting Infinity to integer in String.fromCodePoint().

Dmitry Volyntsev xeioex at nginx.com
Tue Jan 9 17:31:24 UTC 2024


details:   https://hg.nginx.org/njs/rev/f4cb0dc3e8ea
branches:  
changeset: 2262:f4cb0dc3e8ea
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Mon Jan 08 22:21:14 2024 -0800
description:
Avoiding casting Infinity to integer in String.fromCodePoint().

Found by UndefinedBehaviorSanitizer.

diffstat:

 src/njs_string.c |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 5d2a3da0674f -r f4cb0dc3e8ea src/njs_string.c
--- a/src/njs_string.c	Mon Jan 08 22:20:19 2024 -0800
+++ b/src/njs_string.c	Mon Jan 08 22:21:14 2024 -0800
@@ -1617,7 +1617,7 @@ njs_string_from_char_code(njs_vm_t *vm, 
 
         if (is_point) {
             num = njs_number(&args[i]);
-            if (isnan(num)) {
+            if (isnan(num) || isinf(num)) {
                 goto range_error;
             }
 


More information about the nginx-devel mailing list