aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2016-12-07 12:14:07 +0000
committerTatsuya Kinoshita <tats@debian.org>2016-12-07 12:24:44 +0000
commit512ed467d12615f5ef40d0d28272e5662d8438ea (patch)
treee492027cac055b5dfce919356ed8d51ed3de5bc7 /file.c
parentPrevent overflow beyond the end of string in wtf_strwidth() (diff)
downloadw3m-512ed467d12615f5ef40d0d28272e5662d8438ea.tar.gz
w3m-512ed467d12615f5ef40d0d28272e5662d8438ea.zip
Prevent overflow beyond the end of string in proc_mchar()
Bug-Debian: https://github.com/tats/w3m/issues/59
Diffstat (limited to 'file.c')
-rw-r--r--file.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/file.c b/file.c
index 50f6b9a..134df82 100644
--- a/file.c
+++ b/file.c
@@ -2599,6 +2599,8 @@ static void
proc_mchar(struct readbuffer *obuf, int pre_mode,
int width, char **str, Lineprop mode)
{
+ size_t len;
+
check_breakpoint(obuf, pre_mode, *str);
obuf->pos += width;
Strcat_charp_n(obuf->line, *str, get_mclen(*str));
@@ -2607,7 +2609,10 @@ proc_mchar(struct readbuffer *obuf, int pre_mode,
if (**str != ' ')
obuf->prev_ctype = mode;
}
- (*str) += get_mclen(*str);
+ len = get_mclen(*str);
+ if (len > strlen(*str))
+ len = strlen(*str);
+ (*str) += len;
obuf->flag |= RB_NFLUSHED;
}