Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 1/1] prompt: Fix an off-by-one in the overf check in countpromt.
- X-seq: zsh-workers 42285
- From: warepire.ml@xxxxxxxxx
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 1/1] prompt: Fix an off-by-one in the overf check in countpromt.
- Date: Mon, 15 Jan 2018 11:35:58 +0100
- Cc: Warepire <Warepire@xxxxxxxxxxxxxxxxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Zhj0Kqif3kmZ1bgzyeE0vCd+pDGrWaAXskfBWXzWK9A=; b=aXKFhiY2g/NSrC+apdFte7Es8VOESMTQtV29zueTt8U/kVwGQkbiUVxvbEcwB9Igpt 7nntVtW5I4irbqY4RHFDmP8N+uyYJa2KGuIMbHiAlygJUyff7z8dD+h+ueePEpF2cL5K yF+2npedu63bmSUSE02QmjY0+dwGcoXocVuzj/DYNz1AaJdN+LM90UNLEYATKZyz86VH n1c24vxDal1l1VxeTtJUgxmi3Y69up+hlsRdHQEQvZ655udm3LoJgtgkDqiBapJ+u2oM sp9JXUoFLC3fy4YhezPBQeN3BZuYJaWkQrMXcPRg0pyKwuJM3EQ7Eg9p1I4rffy3S9er mG5g==
- In-reply-to: <20180115103558.1258-1-warepire.ml@gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180115103558.1258-1-warepire.ml@gmail.com>
From: Warepire <Warepire@xxxxxxxxxxxxxxxxxxxxxxxx>
This triggers overf when the prompt is exactly as wide as the
term, causes countprompt to count a 2-line prompt as 3 lines.
Which transmits an errorneus TCUP to the PTY. In some terminals
this causes the last line of the previous command to be erased.
Hexdumping the PTY in benign and trouble cases, for my term
TCUP is represented by "\x1b[A". The NOK dumps are when the
prompt is exactly as wide as the term.
OK chunk dump:
0000 0d 1b 5b 30 6d 1b 5b 32 37 6d 1b 5b 32 34 6d 1b ..[0m.[27m.[24m.
0010 5b 4a 1b 5b 33 33 6d 7e 2f 76 74 65 2d 6e 67 2d [J.[33m~/vte-ng-
0020 30 2e 35 30 2e 32 2e 61 1b 5b 30 30 6d 20 0d 0a 0.50.2.a.[00m ..
0030 1b 5b 33 37 6d 77 61 72 65 70 69 72 65 20 25 1b .[37mwarepire %.
0040 5b 30 30 6d 20 1b 5b 4b 1b 5b 36 34 43 1b 5b 30 [00m .[K.[64C.[0
0050 31 3b 33 32 6d e2 9c 94 1b 5b 30 30 6d 20 49 4e 1;32m....[00m IN
0060 53 1b 5b 36 39 44 0d 0d 1b 5b 41 1b 5b 3f 32 30 S.[69D...[A.[?20 <-- Correct number of TCUP
0070 30 34 68 1b 5b 30 6d 1b 5b 32 37 6d 1b 5b 32 34 04h.[0m.[27m.[24
0080 6d 1b 5b 4a 1b 5b 33 33 6d 7e 2f 76 74 65 2d 6e m.[J.[33m~/vte-n
0090 67 2d 30 2e 35 30 2e 32 2e 61 1b 5b 30 30 6d 20 g-0.50.2.a.[00m
00a0 0d 0a 1b 5b 33 37 6d 77 61 72 65 70 69 72 65 20 ...[37mwarepire
00b0 25 1b 5b 30 30 6d 20 1b 5b 4b 1b 5b 36 34 43 1b %.[00m .[K.[64C.
00c0 5b 30 31 3b 33 32 6d e2 9c 94 1b 5b 30 30 6d 20 [01;32m....[00m
00d0 49 4e 53 1b 5b 36 39 44 INS.[69D
NOK chunk dump:
0000 0d 1b 5b 30 6d 1b 5b 32 37 6d 1b 5b 32 34 6d 1b ..[0m.[27m.[24m.
0010 5b 4a 1b 5b 33 33 6d 7e 2f 74 65 73 74 2d 64 69 [J.[33m~/test-di
0020 72 2f 61 61 61 61 61 61 61 61 61 61 61 61 61 61 r/aaaaaaaaaaaaaa
0030 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa
0040 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa
0050 61 61 61 61 61 2f 62 62 62 62 62 62 62 62 62 62 aaaaa/bbbbbbbbbb
0060 62 62 62 2f 63 63 63 1b 5b 30 30 6d 20 0d 0a 1b bbb/ccc.[00m ...
0070 5b 33 37 6d 77 61 72 65 70 69 72 65 20 25 1b 5b [37mwarepire %.[
0080 30 30 6d 20 1b 5b 4b 1b 5b 36 34 43 1b 5b 30 31 00m .[K.[64C.[01
0090 3b 33 32 6d e2 9c 94 1b 5b 30 30 6d 20 49 4e 53 ;32m....[00m INS
00a0 1b 5b 36 39 44 0d 0d 1b 5b 41 1b 5b 41 1b 5b 3f .[69D...[A.[A.[? <--- Incorrect number of TCUP
00b0 32 30 30 34 68 1b 5b 30 6d 1b 5b 32 37 6d 1b 5b 2004h.[0m.[27m.[
00c0 32 34 6d 1b 5b 4a 1b 5b 33 33 6d 7e 2f 74 65 73 24m.[J.[33m~/tes
00d0 74 2d 64 69 72 2f 61 61 61 61 61 61 61 61 61 61 t-dir/aaaaaaaaaa
00e0 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa
00f0 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa
0100 61 61 61 61 61 61 61 61 61 2f 62 62 62 62 62 62 aaaaaaaaa/bbbbbb
0110 62 62 62 62 62 62 62 2f 63 63 63 1b 5b 30 30 6d bbbbbbb/ccc.[00m
0120 20 0d 0a 1b 5b 33 37 6d 77 61 72 65 70 69 72 65 ...[37mwarepire
0130 20 25 1b 5b 30 30 6d 20 1b 5b 4b 1b 5b 36 34 43 %.[00m .[K.[64C
0140 1b 5b 30 31 3b 33 32 6d e2 9c 94 1b 5b 30 30 6d .[01;32m....[00m
0150 20 49 4e 53 1b 5b 36 39 44 INS.[69D
NOK chunks from I/O channel:
0 chars and 0 bytes in 1 chunks left to process.
read/bp:
0000 00 0d 1b 5b 30 6d 1b 5b 32 37 6d 1b 5b 32 34 6d ...[0m.[27m.[24m
0010 1b 5b 4a 1b 5b 33 33 6d 7e 2f 74 65 73 74 2d 64 .[J.[33m~/test-d
0020 69 72 2f 61 61 61 61 61 61 61 61 61 61 61 61 61 ir/aaaaaaaaaaaaa
0030 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa
0040 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa
0050 61 61 61 61 61 61 2f 62 62 62 62 62 62 62 62 62 aaaaaa/bbbbbbbbb
0060 62 62 62 62 2f 63 63 63 1b 5b 30 30 6d 20 0d 0a bbbb/ccc.[00m ..
0070 1b 5b 33 37 6d 77 61 72 65 70 69 72 65 20 25 1b .[37mwarepire %.
0080 5b 30 30 6d 20 [00m
read 132/5355 bytes, again? yes, active? yes
read/bp:
0000 00 1b 5b 4b 1b 5b 36 34 43 1b 5b 30 31 3b 33 32 ..[K.[64C.[01;32
0010 6d e2 9c 94 1b 5b 30 30 6d 20 49 4e 53 1b 5b 36 m....[00m INS.[6
0020 39 44 9D
read 165/5355 bytes, again? yes, active? yes
read/bp:
0000 00 0d 0d 1b 5b 41 1b 5b 41 1b 5b 3f 32 30 30 34 ....[A.[A.[?2004 <--- Incorrect number of TCUP
0010 68 1b 5b 30 6d 1b 5b 32 37 6d 1b 5b 32 34 6d 1b h.[0m.[27m.[24m.
0020 5b 4a 1b 5b 33 33 6d 7e 2f 74 65 73 74 2d 64 69 [J.[33m~/test-di
0030 72 2f 61 61 61 61 61 61 61 61 61 61 61 61 61 61 r/aaaaaaaaaaaaaa
0040 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa
0050 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa
0060 61 61 61 61 61 2f 62 62 62 62 62 62 62 62 62 62 aaaaa/bbbbbbbbbb
0070 62 62 62 2f 63 63 63 1b 5b 30 30 6d 20 0d 0a 1b bbb/ccc.[00m ...
0080 5b 33 37 6d 77 61 72 65 70 69 72 65 20 25 1b 5b [37mwarepire %.[
0090 30 30 6d 20 00m
read 312/5355 bytes, again? yes, active? yes
read/bp:
0000 00 1b 5b 4b 1b 5b 36 34 43 1b 5b 30 31 3b 33 32 ..[K.[64C.[01;32
0010 6d e2 9c 94 1b 5b 30 30 6d 20 49 4e 53 1b 5b 36 m....[00m INS.[6
0020 39 44 9D
Fixes: commit fa699be45debba815ea5e3ed5bfebde280d894a0
Signed-off-by: Warepire <Warepire@xxxxxxxxxxxxxxxxxxxxxxxx>
---
Src/prompt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Src/prompt.c b/Src/prompt.c
index c478e69fb..9b9e33670 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -1087,7 +1087,7 @@ countprompt(char *str, int *wp, int *hp, int overf)
#endif
for (; *str; str++) {
- if (w >= zterm_columns && overf >= 0) {
+ if (w > zterm_columns && overf >= 0) {
w = 0;
h++;
}
--
2.15.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author