about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-11-05 13:27:52 +0100
committerptitSeb <sebastien.chev@gmail.com>2023-11-05 13:27:52 +0100
commiteb6ec17504510a631bfb8a09316e63f71ccce28d (patch)
treea1e75f3671c309914b457d25e84bc085bd6c232e /src
parent8c68e1108bd4a7b2b36ff868db36e5dffda77396 (diff)
downloadbox64-eb6ec17504510a631bfb8a09316e63f71ccce28d.tar.gz
box64-eb6ec17504510a631bfb8a09316e63f71ccce28d.zip
Some fixes to the BOX64_TRACE_FILE setting
Diffstat (limited to 'src')
-rw-r--r--src/main.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index 0d0a61cf..9868a821 100644
--- a/src/main.c
+++ b/src/main.c
@@ -152,19 +152,22 @@ int ftrace_has_pid = 0;
 void openFTrace(const char* newtrace)
 {
     const char* t = newtrace?newtrace:getenv("BOX64_TRACE_FILE");
-    char tmp[500];
-    char tmp2[500];
+    #ifndef MAX_PATH
+    #define MAX_PATH 4096
+    #endif
+    char tmp[MAX_PATH];
+    char tmp2[MAX_PATH];
     const char* p = t;
     int append=0;
     if(p && strlen(p) && p[strlen(p)-1]=='+') {
-        strncat(tmp2, t, 499);
+        strncpy(tmp2, p, sizeof(tmp2));
         tmp2[strlen(p)-1]='\0';
         p = tmp2;
         append=1;
     }
-    if(p && strstr(t, "%pid")) {
+    if(p && strstr(p, "%pid")) {
         int next = 0;
-        if(!append) do {
+        do {
             strcpy(tmp, p);
             char* c = strstr(tmp, "%pid");
             *c = 0; // cut
@@ -177,7 +180,7 @@ void openFTrace(const char* newtrace)
             c = strstr(p, "%pid") + strlen("%pid");
             strcat(tmp, c);
             ++next;
-        } while (FileExist(tmp, IS_FILE));
+        } while (FileExist(tmp, IS_FILE) && !append);
         p = tmp;
         ftrace_has_pid = 1;
     }