diff options
author | Tatsuya Kinoshita <tats@debian.org> | 2016-12-13 13:44:08 +0000 |
---|---|---|
committer | Tatsuya Kinoshita <tats@debian.org> | 2016-12-13 14:04:18 +0000 |
commit | e79d0ec2a00369a6af24007a1f2bb5e876e2c847 (patch) | |
tree | 3e6c57736c73e0c874a51958e124a73f5e2a222f /file.c | |
parent | Prevent overflow beyond the end of string in textfieldrep() (diff) | |
download | w3m-e79d0ec2a00369a6af24007a1f2bb5e876e2c847.tar.gz w3m-e79d0ec2a00369a6af24007a1f2bb5e876e2c847.zip |
Prevent overflow beyond the end of string in proc_mchar()
Bug-Debian: https://github.com/tats/w3m/issues/80
cf. https://github.com/tats/w3m/issues/59
Diffstat (limited to '')
-rw-r--r-- | file.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -2603,19 +2603,20 @@ static void proc_mchar(struct readbuffer *obuf, int pre_mode, int width, char **str, Lineprop mode) { - size_t len; + int len, slen; check_breakpoint(obuf, pre_mode, *str); obuf->pos += width; - Strcat_charp_n(obuf->line, *str, get_mclen(*str)); + len = get_mclen(*str); + slen = (int)strlen(*str); + if (len > slen && slen > 0) + len = slen; + Strcat_charp_n(obuf->line, *str, len); if (width > 0) { set_prevchar(obuf->prevchar, *str, 1); if (**str != ' ') obuf->prev_ctype = mode; } - len = get_mclen(*str); - if (len > strlen(*str)) - len = strlen(*str); (*str) += len; obuf->flag |= RB_NFLUSHED; } |