aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorsogaiu <33044872+sogaiu@users.noreply.github.com>2026-02-15 00:04:33 +0900
committerGitHub <noreply@github.com>2026-02-14 09:04:33 -0600
commitabd7bb111004e84feca5fefe5d65a52300aa6ffa (patch)
treed5527ffdfc63cb73f6b457e84e057c0b0407f690
parentWhen pretty printing, don't sort keys for huge tables. (diff)
Use snprintf instead of sprintf (#1711)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
-rw-r--r--src/boot/system_test.c2
-rw-r--r--src/core/ev.c2
-rw-r--r--src/core/os.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/src/boot/system_test.c b/src/boot/system_test.c
index d0fe41ee..13e2edef 100644
--- a/src/boot/system_test.c
+++ b/src/boot/system_test.c
@@ -37,7 +37,7 @@ int system_test() {
/* Check the version defines are self consistent */
char version_combined[256];
- sprintf(version_combined, "%d.%d.%d%s", JANET_VERSION_MAJOR, JANET_VERSION_MINOR, JANET_VERSION_PATCH, JANET_VERSION_EXTRA);
+ snprintf(version_combined, sizeof(version_combined), "%d.%d.%d%s", JANET_VERSION_MAJOR, JANET_VERSION_MINOR, JANET_VERSION_PATCH, JANET_VERSION_EXTRA);
assert(!strcmp(JANET_VERSION, version_combined));
/* Reflexive testing and nanbox testing */
diff --git a/src/core/ev.c b/src/core/ev.c
index 250ab728..9b03413e 100644
--- a/src/core/ev.c
+++ b/src/core/ev.c
@@ -2416,7 +2416,7 @@ Janet janet_ev_lasterr(void) {
msgbuf,
sizeof(msgbuf),
NULL);
- if (!*msgbuf) sprintf(msgbuf, "%d", code);
+ if (!*msgbuf) snprintf(msgbuf, sizeof(msgbuf), "%d", code);
char *c = msgbuf;
while (*c) {
if (*c == '\n' || *c == '\r') {
diff --git a/src/core/os.c b/src/core/os.c
index 8e514113..bc57b64a 100644
--- a/src/core/os.c
+++ b/src/core/os.c
@@ -1331,7 +1331,7 @@ static Janet os_execute_impl(int32_t argc, Janet *argv, JanetExecuteMode mode) {
msgbuf,
sizeof(msgbuf),
NULL);
- if (!*msgbuf) sprintf(msgbuf, "%d", cp_error_code);
+ if (!*msgbuf) snprintf(msgbuf, sizeof(msgbuf), "%d", cp_error_code);
char *c = msgbuf;
while (*c) {
if (*c == '\n' || *c == '\r') {