aboutsummaryrefslogtreecommitdiffstats
path: root/libwc
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2016-12-07 16:00:42 +0000
committerTatsuya Kinoshita <tats@debian.org>2016-12-07 16:00:42 +0000
commita56a8ef132945512c010cbcbc873dbb42274f9bd (patch)
tree5b3b1564dd82d721f00e7c10374fa6d4bde839a6 /libwc
parentRevert "Prevent overflow beyond the end of string in wtf_strwidth()" (diff)
downloadw3m-a56a8ef132945512c010cbcbc873dbb42274f9bd.tar.gz
w3m-a56a8ef132945512c010cbcbc873dbb42274f9bd.zip
Prevent overflow beyond the end of string in wtf_strwidth()
Bug-Debian: https://github.com/tats/w3m/issues/57
Diffstat (limited to 'libwc')
-rw-r--r--libwc/wtf.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libwc/wtf.c b/libwc/wtf.c
index b8cfdc7..83839d7 100644
--- a/libwc/wtf.c
+++ b/libwc/wtf.c
@@ -120,8 +120,9 @@ int
wtf_strwidth(wc_uchar *p)
{
int w = 0;
+ wc_uchar *q = p + strlen(p);
- while (*p) {
+ while (p < q) {
w += wtf_width(p);
p += WTF_LEN_MAP[*p];
}