Fix a possible buffer overflow in FAIL() when writing to the stacktrace buffer

This commit is contained in:
2026-01-10 08:41:06 -05:00
parent cf0f2bbeac
commit 3e4f0d1cda
2 changed files with 2 additions and 2 deletions

View File

@@ -4,7 +4,7 @@ project(akerror LANGUAGES C)
include(GNUInstallDirs) include(GNUInstallDirs)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
set(AKERROR_USE_STDLIB 1 CACHE BOOL "Use C standard library for error logging") set(AKERROR_USE_STDLIB 1 CACHE BOOL "Use the C standard library")
set(akerror_install_cmakedir "${CMAKE_INSTALL_LIBDIR}/cmake/akerror") set(akerror_install_cmakedir "${CMAKE_INSTALL_LIBDIR}/cmake/akerror")
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)

View File

@@ -154,7 +154,7 @@ void error_default_logger(const char *f, ...);
snprintf((char *)__err_context->function, MAX_ERROR_FUNCTION_LENGTH, __func__); \ snprintf((char *)__err_context->function, MAX_ERROR_FUNCTION_LENGTH, __func__); \
__err_context->lineno = __LINE__; \ __err_context->lineno = __LINE__; \
snprintf((char *)__err_context->message, MAX_ERROR_CONTEXT_STRING_LENGTH, __message, ## __VA_ARGS__); \ snprintf((char *)__err_context->message, MAX_ERROR_CONTEXT_STRING_LENGTH, __message, ## __VA_ARGS__); \
__err_context->stacktracebufptr += sprintf(__err_context->stacktracebufptr, "%s:%s:%d: %d (%s) : %s\n", (char *)__err_context->fname, (char *)__err_context->function, __err_context->lineno, __err_context->status, error_name_for_status(__err_context->status, NULL), __err_context->message); __err_context->stacktracebufptr += snprintf(__err_context->stacktracebufptr, MAX_ERROR_STACKTRACE_BUF_LENGTH, "%s:%s:%d: %d (%s) : %s\n", (char *)__err_context->fname, (char *)__err_context->function, __err_context->lineno, __err_context->status, error_name_for_status(__err_context->status, NULL), __err_context->message);
#define SUCCEED(__err_context) \ #define SUCCEED(__err_context) \