diff --git a/src/cli.c b/src/cli.c index 1f14abe..8d9477f 100644 --- a/src/cli.c +++ b/src/cli.c @@ -374,8 +374,16 @@ int index_args_validate(index_args_t *args, int argc, const char **argv) { LOG_DEBUGF("cli.c", "arg es_index=%s", args->es_index) LOG_DEBUGF("cli.c", "arg index_path=%s", args->index_path) LOG_DEBUGF("cli.c", "arg script_path=%s", args->script_path) - LOG_DEBUGF("cli.c", "arg async_script=%s", args->async_script) - LOG_DEBUGF("cli.c", "arg script=%s", args->script) + + char log_buf[5000]; + strncpy(log_buf, args->script, sizeof(log_buf)); + *(log_buf + sizeof(log_buf) - 1) = '\0'; + LOG_DEBUGF("cli.c", "arg async_script=%s", log_buf) + + strncpy(log_buf, args->script, sizeof(log_buf)); + *(log_buf + sizeof(log_buf) - 1) = '\0'; + LOG_DEBUGF("cli.c", "arg script=%s", log_buf) + LOG_DEBUGF("cli.c", "arg print=%d", args->print) LOG_DEBUGF("cli.c", "arg es_mappings_path=%s", args->es_mappings_path) LOG_DEBUGF("cli.c", "arg es_mappings=%s", args->es_mappings) @@ -535,6 +543,11 @@ int exec_args_validate(exec_args_t *args, int argc, const char **argv) { } LOG_DEBUGF("cli.c", "arg script_path=%s", args->script_path) - LOG_DEBUGF("cli.c", "arg script=%s", args->script) + + char log_buf[5000]; + strncpy(log_buf, args->script, sizeof(log_buf)); + *(log_buf + sizeof(log_buf) - 1) = '\0'; + LOG_DEBUGF("cli.c", "arg script=%s", log_buf) + return 0; } diff --git a/src/log.c b/src/log.c index d5a5a29..5453a84 100644 --- a/src/log.c +++ b/src/log.c @@ -48,6 +48,12 @@ void vsist_logf(const char *filepath, int level, char *format, va_list ap) { size_t maxsize = sizeof(log_str) - log_len; log_len += vsnprintf(log_str + log_len, maxsize, format, ap); + if (log_len >= maxsize) { + fprintf(stderr, "([%s] FIXME: Log string is too long to display: %dB)\n", + log_levels[level], log_len); + return; + } + if (is_tty) { log_len += sprintf(log_str + log_len, "\033[0m\n"); } else {