]> git.proxmox.com Git - mirror_qemu.git/blobdiff - trace/ftrace.c
Merge tag 'linux-user-for-8.1-pull-request' of https://github.com/vivier/qemu into...
[mirror_qemu.git] / trace / ftrace.c
index 61692a8682984a24cafd438e907f4d3bf06417ed..9749543d9b2424fe739afc4ea9ac47cdb88abfed 100644 (file)
@@ -53,7 +53,11 @@ bool ftrace_init(void)
     }
 
     if (tracefs_found) {
-        snprintf(path, PATH_MAX, "%s%s/tracing_on", mount_point, subdir);
+        if (snprintf(path, PATH_MAX, "%s%s/tracing_on", mount_point, subdir)
+                >= sizeof(path)) {
+            fprintf(stderr, "Using tracefs mountpoint would exceed PATH_MAX\n");
+            return false;
+        }
         trace_fd = open(path, O_WRONLY);
         if (trace_fd < 0) {
             if (errno == EACCES) {
@@ -72,7 +76,11 @@ bool ftrace_init(void)
             }
             close(trace_fd);
         }
-        snprintf(path, PATH_MAX, "%s%s/trace_marker", mount_point, subdir);
+        if (snprintf(path, PATH_MAX, "%s%s/trace_marker", mount_point, subdir)
+                >= sizeof(path)) {
+            fprintf(stderr, "Using tracefs mountpoint would exceed PATH_MAX\n");
+            return false;
+        }
         trace_marker_fd = open(path, O_WRONLY);
         if (trace_marker_fd < 0) {
             perror("Could not open ftrace 'trace_marker' file");