From cdda7838f667ccfdac67b3ad08600ee252743ef3 Mon Sep 17 00:00:00 2001 From: Matt Jones <47545907+SoundMatt@users.noreply.github.com> Date: Sun, 26 Jul 2026 10:37:01 -0700 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20v0.5.38=20=E2=80=94=20realpath=20buf?= =?UTF-8?q?fer=20overflow=20in=20cmd=5Finit=20on=20ubuntu-22.04?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SoundMatt Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com> --- CHANGELOG.md | 10 ++++++++++ cmd/cfusa/cmd_init.c | 5 +++-- include/cfusa/version.h | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e80b46f..c52e88f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,16 @@ and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0. ## [Unreleased] +## v0.5.38 — 2026-07-26 + +### Fixed +- **[P0] realpath buffer too small in cmd_init** — replaced `char resolved[512]` with + `realpath(dir, NULL)` (dynamic allocation) to fix glibc `_FORTIFY_SOURCE=2` abort on + ubuntu-22.04. `__realpath_chk` requires the destination buffer to be at least `PATH_MAX` + (4096 bytes); the 512-byte stack buffer triggered `*** buffer overflow detected ***` + during `cfusa init --docs --dir ` (test_init_docs_generates_templates), aborting + all remaining CLI tests in the Release CI build. + ## v0.5.37 — 2026-07-26 ### Fixed diff --git a/cmd/cfusa/cmd_init.c b/cmd/cfusa/cmd_init.c index 1f75daa..85fb3fb 100644 --- a/cmd/cfusa/cmd_init.c +++ b/cmd/cfusa/cmd_init.c @@ -59,11 +59,12 @@ int cmd_init(int argc, char **argv) char dir_basename[256] = "project"; if (!project) { const char *abs = dir; - char resolved[512]; - if (realpath(dir, resolved)) abs = resolved; + char *resolved = realpath(dir, NULL); + if (resolved) abs = resolved; const char *slash = strrchr(abs, '/'); strncpy(dir_basename, slash ? slash + 1 : abs, sizeof(dir_basename) - 1); project = dir_basename; + free(resolved); } cfusa_config_t cfg; diff --git a/include/cfusa/version.h b/include/cfusa/version.h index c2dfac4..35f2352 100644 --- a/include/cfusa/version.h +++ b/include/cfusa/version.h @@ -3,8 +3,8 @@ #define CFUSA_VERSION_MAJOR 0 #define CFUSA_VERSION_MINOR 5 -#define CFUSA_VERSION_PATCH 36 -#define CFUSA_VERSION_STRING "0.5.37" +#define CFUSA_VERSION_PATCH 38 +#define CFUSA_VERSION_STRING "0.5.38" #define CFUSA_SCHEMA_VERSION "1.10.4" #define CFUSA_SPEC_VERSION "1.10.4" From b04674da558e257673d223c7d7ddb1989e736ee9 Mon Sep 17 00:00:00 2001 From: Matt Jones <47545907+SoundMatt@users.noreply.github.com> Date: Sun, 26 Jul 2026 10:47:32 -0700 Subject: [PATCH 2/2] fix: add _GNU_SOURCE guard to cmd_init.c for realpath declaration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without #define _GNU_SOURCE, realpath() is not declared from on strict POSIX/C99 builds. clang-15 failed with an undeclared-function error; gcc compiled with an implicit int-returning declaration which truncates the 64-bit pointer return value, causing free() to segfault. All other cmd/*.c files already carry the guard — align cmd_init.c. Signed-off-by: SoundMatt Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com> --- cmd/cfusa/cmd_init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/cfusa/cmd_init.c b/cmd/cfusa/cmd_init.c index 85fb3fb..1558ced 100644 --- a/cmd/cfusa/cmd_init.c +++ b/cmd/cfusa/cmd_init.c @@ -1,3 +1,6 @@ +#if defined(__linux__) || defined(__unix__) +# define _GNU_SOURCE +#endif #include #include #include