summaryrefslogtreecommitdiff
path: root/src/fe-common/core/formats.c
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2017-01-03 13:44:58 +0100
committerailin-nemui <ailin-nemui@users.noreply.github.com>2017-01-03 13:44:58 +0100
commit78ba05985d8fed883a8b26ffef4878acdae58fff (patch)
tree733934527ce98cb4c9ecdd7fb20001650fabcd53 /src/fe-common/core/formats.c
parent01163710e71318c6c2fd3f797f6b878f92b7f97b (diff)
parent7a112e021724af582a06eed8f92fafb772438c13 (diff)
downloadirssi-78ba05985d8fed883a8b26ffef4878acdae58fff.zip
Merge branch 'security' into 'master'
See merge request !7
Diffstat (limited to 'src/fe-common/core/formats.c')
-rw-r--r--src/fe-common/core/formats.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c
index a58d839a..17c13a97 100644
--- a/src/fe-common/core/formats.c
+++ b/src/fe-common/core/formats.c
@@ -68,7 +68,7 @@ static void format_expand_code(const char **format, GString *out, int *flags)
if (flags == NULL) {
/* flags are being ignored - skip the code */
- while (**format != ']')
+ while (**format != ']' && **format != '\0')
(*format)++;
return;
}
@@ -246,6 +246,10 @@ int format_expand_styles(GString *out, const char **format, int *flags)
case '[':
/* code */
format_expand_code(format, out, flags);
+ if ((*format)[0] == '\0')
+ /* oops, reached end prematurely */
+ (*format)--;
+
break;
case 'x':
case 'X':
@@ -956,6 +960,7 @@ static const char *get_ansi_color(THEME_REC *theme, const char *str,
str++;
for (num2 = 0; i_isdigit(*str); str++)
num2 = num2*10 + (*str-'0');
+ if (*str == '\0') return start;
switch (num2) {
case 2:
@@ -973,6 +978,8 @@ static const char *get_ansi_color(THEME_REC *theme, const char *str,
for (; i_isdigit(*str); str++)
num2 = (num2&~0xff) |
(((num2&0xff) * 10 + (*str-'0'))&0xff);
+
+ if (*str == '\0') return start;
}
if (i == -1) break;
@@ -1001,6 +1008,7 @@ static const char *get_ansi_color(THEME_REC *theme, const char *str,
str++;
for (num2 = 0; i_isdigit(*str); str++)
num2 = num2*10 + (*str-'0');
+ if (*str == '\0') return start;
if (num == 38) {
flags &= ~GUI_PRINT_FLAG_COLOR_24_FG;