Welcome! Log In Create A New Profile

Advanced

[njs] Fixed handling of encode arg in fs.readdir() and fs.realpath().

Anonymous User
September 04, 2024 12:38PM
details: https://github.com/nginx/njs/commit/6259cca26b6747fa8ade15c4b602b9ad190cb14a
branches: master
commit: 6259cca26b6747fa8ade15c4b602b9ad190cb14a
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue, 3 Sep 2024 21:32:33 -0700
description:
Fixed handling of encode arg in fs.readdir() and fs.realpath().

The issue was introduced in 98c6570f3 (0.8.0).

---
external/njs_fs_module.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/external/njs_fs_module.c b/external/njs_fs_module.c
index 5f9a48e2..de378cee 100644
--- a/external/njs_fs_module.c
+++ b/external/njs_fs_module.c
@@ -1940,14 +1940,19 @@ njs_fs_readdir(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,

encoding = NULL;

- if (!njs_value_is_string(njs_value_arg(&encode))) {
+
+ if (njs_value_is_string(njs_value_arg(&encode))) {
njs_value_string_get(njs_value_arg(&encode), &s);

- if (!njs_strstr_eq(&s, &string_buffer)) {
- encoding = njs_buffer_encoding(vm, njs_value_arg(&encode), 1);
- if (njs_slow_path(encoding == NULL)) {
- return NJS_ERROR;
- }
+ } else {
+ s.length = 0;
+ s.start = NULL;
+ }
+
+ if (!njs_strstr_eq(&s, &string_buffer)) {
+ encoding = njs_buffer_encoding(vm, njs_value_arg(&encode), 1);
+ if (njs_slow_path(encoding == NULL)) {
+ return NJS_ERROR;
}
}

@@ -2080,14 +2085,18 @@ njs_fs_realpath(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,

encoding = NULL;

- if (!njs_value_is_string(njs_value_arg(&encode))) {
+ if (njs_value_is_string(njs_value_arg(&encode))) {
njs_value_string_get(njs_value_arg(&encode), &s);

- if (!njs_strstr_eq(&s, &string_buffer)) {
- encoding = njs_buffer_encoding(vm, njs_value_arg(&encode), 1);
- if (njs_slow_path(encoding == NULL)) {
- return NJS_ERROR;
- }
+ } else {
+ s.length = 0;
+ s.start = NULL;
+ }
+
+ if (!njs_strstr_eq(&s, &string_buffer)) {
+ encoding = njs_buffer_encoding(vm, njs_value_arg(&encode), 1);
+ if (njs_slow_path(encoding == NULL)) {
+ return NJS_ERROR;
}
}

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

[njs] Fixed handling of encode arg in fs.readdir() and fs.realpath().

Anonymous User 165 September 04, 2024 12:38PM



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

Online Users

Guests: 147
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