CodeQL / Uncontrolled data used in path expression
This argument to a file access function is derived from user input (an environment variable) and then passed to open(__file).
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
This argument to a file access function is derived from user input (an environment variable) and then passed to open(__file).
Risk: low. Approved. Cursor Security Agent completed with no findings that need human review; Cursor Bugbot was not present on this PR.
<div><a href="https://cursor.com/agents/bc-7a8b5868-c6c0-4eef-b292-041c66929c35?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/automations/ca4a13aa-d616-11f1-a7e4-4605a90eab71"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/view-automation-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/view-automation-light.png"><img alt="View Automation" width="141" height="28" src="https://cursor.com/assets/images/view-automation-dark.png"></picture></a> </div>
<sub>Sent by Cursor Approval Agent: Pull Request Router and Approver</sub>
curl -fsSL https://interplane.io/drakestapleton/CUDApp/patches/397c4d5dec4b1d34.bundle -o 397c4d5dec4b1d34.bundle git fetch 397c4d5dec4b1d34.bundle refs/pull/256/head
github-import 1
aien-dev/CUDApp
256
f9c1c8a5b25799ce27bfd8b1ab39b6f202932817
{"kind":"github-import","owner":"aien-dev","repo":"CUDApp","number":256,"url":"https://github.com/aien-dev/CUDApp/pull/256","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:39:02Z","metadata":"unavailable","state_derived":true}
diff --git a/tools/ampere_corpus.c b/tools/ampere_corpus.c index 99208f9e..c71ad09c 100644 --- a/tools/ampere_corpus.c +++ b/tools/ampere_corpus.c @@ -8,6 +8,8 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <fcntl.h> +#include <sys/stat.h> static int is_safe_corpus_dir(const char *dir) { @@ -28,8 +30,10 @@ static void save(const char *dir, unsigned serial, const char *suffix, const voi char path[4096]; int n = snprintf(path, sizeof(path), "%s/%ld-%u.%s", dir, (long)getpid(), serial, suffix); if (n < 0 || (size_t)n >= sizeof(path)) abort(); - FILE *f = fopen(path, "wb"); - if (!f) { perror(path); abort(); } + int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); + if (fd < 0) { perror(path); abort(); } + FILE *f = fdopen(fd, "wb"); + if (!f) { perror(path); close(fd); abort(); } if (fwrite(data, 1, size, f) != size || fclose(f) != 0) abort(); }