summaryrefslogtreecommitdiffstats
path: root/text-utils/more.c
diff options
context:
space:
mode:
authorKarel Zak2013-08-01 16:41:50 +0200
committerKarel Zak2013-08-01 17:03:27 +0200
commit418cb4b3bb7a61aec62ebe91194f7722ea608842 (patch)
tree4c04ca60336cec27c00e3d6184acfd055e5442f3 /text-utils/more.c
parentmore: check for buffer size when write multibyte char (diff)
downloadkernel-qcow2-util-linux-418cb4b3bb7a61aec62ebe91194f7722ea608842.tar.gz
kernel-qcow2-util-linux-418cb4b3bb7a61aec62ebe91194f7722ea608842.tar.xz
kernel-qcow2-util-linux-418cb4b3bb7a61aec62ebe91194f7722ea608842.zip
more: guarantee space for multibyte
.. to make the code more robust. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'text-utils/more.c')
-rw-r--r--text-utils/more.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/text-utils/more.c b/text-utils/more.c
index 9af15b3ff..ac35acc0b 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -1030,6 +1030,12 @@ int get_line(register FILE *f, int *length)
if (column >= Mcol && fold_opt)
break;
+#ifdef HAVE_WIDECHAR
+ if (use_mbc_buffer_flag == 0 && p >= &Line[LineLen - 1 - 4])
+ /* don't read another char if there is no space for
+ * whole multibyte sequence */
+ break;
+#endif
c = Getc(f);
}
if (column >= Mcol && Mcol > 0) {