[vlc-commits] vlc_stream_ReadLine: fix off-by-one

Rémi Denis-Courmont git at videolan.org
Wed May 24 19:02:11 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed May 24 19:47:12 2017 +0300| [dbb8a1891fd41938897b66d58aa8b012695d7f30] | committer: Rémi Denis-Courmont

vlc_stream_ReadLine: fix off-by-one

Do not erase the last converted byte. This bug has apparently existed
ever since UTF-16 support was added.

If the conversion fails, this bug resulted in a heap underflow (writing
zero right before the beginning of the buffer).

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

 src/input/stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/input/stream.c b/src/input/stream.c
index e0c70b42cc..a1eb20ec9e 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -336,7 +336,7 @@ char *vlc_stream_ReadLine( stream_t *s )
             p_line[i_line-2] == '\n') ) i_line--;
 
         /* Make sure the \0 is there */
-        p_line[i_line-1] = '\0';
+        p_line[i_line] = '\0';
 
         return p_line;
     }



More information about the vlc-commits mailing list