diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-03-01 06:49:27 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-03-01 06:49:27 -0800 |
commit | 286dc9dabd46432fe60b55c9ae0c8d5d735fd466 (patch) | |
tree | f6150849a3c7f68a0ee315fa6ed06b6cdd55e3a3 /parser.c | |
parent | 98559fa14d11f0f45a7f57a89149aef48747b00b (diff) | |
download | txr-286dc9dabd46432fe60b55c9ae0c8d5d735fd466.tar.gz txr-286dc9dabd46432fe60b55c9ae0c8d5d735fd466.tar.bz2 txr-286dc9dabd46432fe60b55c9ae0c8d5d735fd466.zip |
listener: fix buffer overflow loading overlong history line.
* parser.c (lino_getl): Same fixes that were applied two weeks
ago to lino_gets in commit b76c5760. Always check for copy and paste!
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 7 |
1 files changed, 1 insertions, 6 deletions
@@ -1474,7 +1474,7 @@ static wchar_t *lino_getl(mem_t *stream_in, wchar_t *buf, size_t nchar) if (nchar == 0) return buf; - while (nchar > 1) { + while (nchar-- > 1) { val ch = get_char(stream); if (!ch) break; @@ -1482,11 +1482,6 @@ static wchar_t *lino_getl(mem_t *stream_in, wchar_t *buf, size_t nchar) break; } - if (ptr == buf) { - *ptr++ = 0; - return 0; - } - *ptr++ = 0; return buf; } |