summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-01-08 14:40:53 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-01-08 14:40:53 +0000
commite2f34de7de4ed14024e13486ab48f04884e2a7b2 (patch)
tree601b9e7c7d204ddadb810f956a2cd5f0a220f303 /usr.bin
parent7f288945c56301f34ea4f95b7c715b915d0021a8 (diff)
Do not hang in format_trim_* on invalid UTF-8 characters.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/format-draw.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/tmux/format-draw.c b/usr.bin/tmux/format-draw.c
index 441bfe7fc4e..c4264cde02a 100644
--- a/usr.bin/tmux/format-draw.c
+++ b/usr.bin/tmux/format-draw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format-draw.c,v 1.13 2019/09/15 21:42:57 nicm Exp $ */
+/* $OpenBSD: format-draw.c,v 1.14 2020/01/08 14:40:52 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -849,8 +849,10 @@ format_trim_left(const char *expanded, u_int limit)
out += ud.size;
}
width += ud.width;
- } else
+ } else {
cp -= ud.have;
+ cp++;
+ }
} else if (*cp > 0x1f && *cp < 0x7f) {
if (width + 1 <= limit)
*out++ = *cp;
@@ -896,8 +898,10 @@ format_trim_right(const char *expanded, u_int limit)
out += ud.size;
}
width += ud.width;
- } else
+ } else {
cp -= ud.have;
+ cp++;
+ }
} else if (*cp > 0x1f && *cp < 0x7f) {
if (width >= skip)
*out++ = *cp;