aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorsogaiu <33044872+sogaiu@users.noreply.github.com>2026-02-17 00:12:02 +0900
committerGitHub <noreply@github.com>2026-02-16 09:12:02 -0600
commitb6676f350c7e30779a3ad9420748c4b1d5ce2557 (patch)
treec18c8d1946ce781cb45a104567368ca6d8a61a78
parentCode defensively with regard to stack resizes from custom get and put (diff)
Use snprintf instead of sprintf - sequel (#1713)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
-rw-r--r--src/core/ev.c9
-rw-r--r--src/core/os.c2
2 files changed, 6 insertions, 5 deletions
diff --git a/src/core/ev.c b/src/core/ev.c
index 9b03413e..b6d85376 100644
--- a/src/core/ev.c
+++ b/src/core/ev.c
@@ -2948,10 +2948,11 @@ int janet_make_pipe(JanetHandle handles[2], int mode) {
if (!CreatePipe(handles, handles + 1, &saAttr, 0)) return -1;
return 0;
}
- sprintf(PipeNameBuffer,
- "\\\\.\\Pipe\\JanetPipeFile.%08x.%08x",
- (unsigned int) GetCurrentProcessId(),
- (unsigned int) InterlockedIncrement(&PipeSerialNumber));
+ snprintf(PipeNameBuffer,
+ sizeof(PipeNameBuffer),
+ "\\\\.\\Pipe\\JanetPipeFile.%08x.%08x",
+ (unsigned int) GetCurrentProcessId(),
+ (unsigned int) InterlockedIncrement(&PipeSerialNumber));
/* server handle goes to subprocess */
shandle = CreateNamedPipeA(
diff --git a/src/core/os.c b/src/core/os.c
index 76b58aff..21510575 100644
--- a/src/core/os.c
+++ b/src/core/os.c
@@ -2579,7 +2579,7 @@ JANET_CORE_FN(os_dir,
char pattern[MAX_PATH + 1];
if (strlen(dir) > (sizeof(pattern) - 3))
janet_panicf("path too long: %s", dir);
- sprintf(pattern, "%s/*", dir);
+ snprintf(pattern, sizeof(pattern), "%s/*", dir);
intptr_t res = _findfirst(pattern, &afile);
if (-1 == res) janet_panicv(janet_cstringv(janet_strerror(errno)));
do {