Welcome! Log In Create A New Profile

Advanced

[njs] Modules: adding NUL byte at the end of the module body.

Anonymous User
June 28, 2024 11:02PM
details: https://hg.nginx.org/njs/rev/818ab94037d7
branches:
changeset: 2364:818ab94037d7
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue Jun 18 23:47:31 2024 -0700
description:
Modules: adding NUL byte at the end of the module body.

Even though QuickJS takes length as an argument, when parsing the code,
it expects NUL byte at the end.

diffstat:

nginx/ngx_js.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diffs (21 lines):

diff -r f358df45922c -r 818ab94037d7 nginx/ngx_js.c
--- a/nginx/ngx_js.c Fri Jun 21 17:58:32 2024 -0700
+++ b/nginx/ngx_js.c Tue Jun 18 23:47:31 2024 -0700
@@ -1841,7 +1841,7 @@ ngx_js_module_read(njs_mp_t *mp, int fd,

text->length = sb.st_size;

- text->start = njs_mp_alloc(mp, text->length);
+ text->start = njs_mp_alloc(mp, text->length + 1);
if (text->start == NULL) {
goto fail;
}
@@ -1852,6 +1852,8 @@ ngx_js_module_read(njs_mp_t *mp, int fd,
goto fail;
}

+ text->start[text->length] = '\0';
+
return NJS_OK;

fail:
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Modules: adding NUL byte at the end of the module body.

Anonymous User 345 June 28, 2024 11:02PM



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

Online Users

Guests: 132
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready