[vlc-commits] vlc_stream_ReadLine: fix trimming 8-bits lines (fixes #18364)

Rémi Denis-Courmont git at videolan.org
Fri May 26 21:45:41 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri May 26 22:37:31 2017 +0300| [27849047fcbe691801f690d41232cf5b3371dd23] | committer: Rémi Denis-Courmont

vlc_stream_ReadLine: fix trimming 8-bits lines (fixes #18364)

The conversion from UTF-16 to UTF-8 could (until a few days ago) fail
before the end. In that case, the appended nul terminator would not be
converted. A nul terminator is anyway always appended after conversion
and trimming.

If conversion failed on the first character, that nul terminator would
be written at a negative offset, leading to heap buffer "underflow" and
memory corruption. This was fixed but lead to a mismatch in the value of
i_lines depending on the character width.

This change removes the useless pre-conversion nul terminator, and thus
makes trimming work again with single byte character width work. This
fixes reading text files formatted with MS-DOS line endings.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=27849047fcbe691801f690d41232cf5b3371dd23
---

 src/input/stream.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/input/stream.c b/src/input/stream.c
index 1191e99b3d..ac4073dc06 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -299,9 +299,6 @@ char *vlc_stream_ReadLine( stream_t *s )
 
     if( i_read > 0 )
     {
-        memset(p_line + i_line, 0, priv->text.char_width);
-        i_line += priv->text.char_width; /* the added \0 */
-
         if( priv->text.char_width > 1 )
         {
             int i_new_line = 0;



More information about the vlc-commits mailing list