1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

fix out of bounds read in compress_colors

Reported by Hanno Böck.

Fixes GL#12
This commit is contained in:
ailin-nemui 2017-10-07 20:45:13 +02:00
parent 92dbb1895b
commit 00c80cb6fc

View File

@ -587,7 +587,7 @@ static char *theme_format_compress_colors(THEME_REC *theme, const char *format)
/* a normal character */ /* a normal character */
g_string_append_c(str, *format); g_string_append_c(str, *format);
format++; format++;
} else { } else if (format[1] != '\0') {
/* %format */ /* %format */
format++; format++;
if (IS_OLD_FORMAT(*format, last_fg, last_bg)) { if (IS_OLD_FORMAT(*format, last_fg, last_bg)) {
@ -614,6 +614,11 @@ static char *theme_format_compress_colors(THEME_REC *theme, const char *format)
last_bg = '\0'; last_bg = '\0';
} }
format++; format++;
} else {
/* % at end of string */
format++;
g_string_append_c(str, '%');
g_string_append_c(str, '%');
} }
} }