aboutsummaryrefslogtreecommitdiffstats
path: root/form.c
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2016-12-13 13:24:54 +0000
committerTatsuya Kinoshita <tats@debian.org>2016-12-13 13:24:54 +0000
commit77d8d8d6576d8afc0f6b2e09bb88c7ca9dba58bb (patch)
tree80cf858a29eca702d926d02992dfe7c72bb2e51e /form.c
parentPreserve one byte for end of string character in form_update_line() (diff)
downloadw3m-77d8d8d6576d8afc0f6b2e09bb88c7ca9dba58bb.tar.gz
w3m-77d8d8d6576d8afc0f6b2e09bb88c7ca9dba58bb.zip
Prevent overflow beyond the end of string in textfieldrep()
Bug-Debian: https://github.com/tats/w3m/issues/79
Diffstat (limited to 'form.c')
-rw-r--r--form.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/form.c b/form.c
index fdad786..9c40b44 100644
--- a/form.c
+++ b/form.c
@@ -526,6 +526,8 @@ textfieldrep(Str s, int width)
for (i = 0; i < s->length; i += c_len) {
c_type = get_mctype((unsigned char *)&s->ptr[i]);
c_len = get_mclen(&s->ptr[i]);
+ if (i + c_len > s->length)
+ break;
if (s->ptr[i] == '\r')
continue;
k = j + get_mcwidth(&s->ptr[i]);