Module: kamailio
Branch: master
Commit: 1f5afd3044dd399a7a8b03430c9d2b899d044b5a
URL: 
https://github.com/kamailio/kamailio/commit/1f5afd3044dd399a7a8b03430c9d2b899d044b5a

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-05-08T10:08:21+02:00

app_jsdt: use snprintf() to build path instead of strcat()

---

Modified: src/modules/app_jsdt/app_jsdt_api.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/1f5afd3044dd399a7a8b03430c9d2b899d044b5a.diff
Patch: 
https://github.com/kamailio/kamailio/commit/1f5afd3044dd399a7a8b03430c9d2b899d044b5a.patch

---

diff --git a/src/modules/app_jsdt/app_jsdt_api.c 
b/src/modules/app_jsdt/app_jsdt_api.c
index 93383860379..53464f3ced5 100644
--- a/src/modules/app_jsdt/app_jsdt_api.c
+++ b/src/modules/app_jsdt/app_jsdt_api.c
@@ -459,7 +459,7 @@ static int jsdt_load_dir(duk_context *ctx, const char *path)
        DIR *directory = NULL;
        struct dirent *dir_entry = NULL;
        size_t size_to_allocate = 0;
-       char full_path_to_file[255] = {0};
+       char full_path_to_file[512] = {0};
        size_t name_len = 0;
 
        directory = opendir(_sr_jsdt_load_dir.s);
@@ -474,9 +474,8 @@ static int jsdt_load_dir(duk_context *ctx, const char *path)
                        name_len = strlen(dir_entry->d_name);
                        if(name_len >= 3
                                        && strcmp(dir_entry->d_name + name_len 
- 3, ".js") == 0) {
-                               strcpy(full_path_to_file, _sr_jsdt_load_dir.s);
-                               strcat(full_path_to_file, "/");
-                               strcat(full_path_to_file, dir_entry->d_name);
+                               snprintf(full_path_to_file, 512, "%s/%s", 
_sr_jsdt_load_dir.s,
+                                               dir_entry->d_name);
 
                                LM_DBG("loading js script file: %s from folder 
%.*s\n",
                                                dir_entry->d_name, 
_sr_jsdt_load_dir.len,

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to