Skip to content

Commit

Permalink
Fixed #228 stack smashing detected
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeke committed Sep 5, 2018
1 parent 8b3fe78 commit afdd961
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/TemplateFormatter.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,29 @@ void seaslog_template_formatter(smart_str *xbuf TSRMLS_DC, int generate_type, co
char char_buf[2];
smart_str tmp_buf = {0};

char level_template[100];
level_template[0] = '\0';
char level_template[SEASLOG_BUFFER_MAX_SIZE];
int level_format_start = 0;
int level_format_stop = 0;
int level_format_over = 0;
int level_format_index = 0;

if (SEASLOG_GENERATE_CURRENT_TEMPLATE == generate_type)
{
level_template[0] = '\0';
}

while (*fmt)
{
if (*fmt != '%')
{
INS_CHAR_NR(xbuf, *fmt);
if (!level_format_stop)
if (SEASLOG_GENERATE_CURRENT_TEMPLATE == generate_type)
{
level_template[level_format_index] = *fmt;
level_format_index++;
if (level_format_stop == 0)
{
level_template[level_format_index] = *fmt;
level_format_index++;
}
}
}
else
Expand Down Expand Up @@ -306,6 +313,7 @@ void seaslog_template_formatter(smart_str *xbuf TSRMLS_DC, int generate_type, co
break;
}
}

if (!EXIST_CHAR(xbuf))
{
INS_STRING(xbuf, "", 0);
Expand Down

0 comments on commit afdd961

Please sign in to comment.