[vlc-commits] stream: do not pass NULL buffer to access module
Rémi Denis-Courmont
git at videolan.org
Tue Feb 7 20:52:35 CET 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Feb 7 19:56:46 2017 +0200| [dc513b6d375d85cb07e95918bfe965d59410bd81] | committer: Rémi Denis-Courmont
stream: do not pass NULL buffer to access module
access_t.pf_read did not expect a NULL output pointer before the merge
of access_t and stream_t. For files, this caused an EFAULT error, but
for other input types, it would likely crash.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dc513b6d375d85cb07e95918bfe965d59410bd81
---
src/input/stream.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/input/stream.c b/src/input/stream.c
index 7138280..f63ca1f 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -364,7 +364,16 @@ static ssize_t vlc_stream_ReadRaw(stream_t *s, void *buf, size_t len)
if (s->pf_read != NULL)
{
assert(priv->block == NULL);
- ret = s->pf_read(s, buf, len);
+ if (buf == NULL)
+ {
+ if (unlikely(len == 0))
+ return 0;
+
+ char dummy[(len <= 256 ? len : 256)];
+ ret = s->pf_read(s, dummy, sizeof (dummy));
+ }
+ else
+ ret = s->pf_read(s, buf, len);
return ret;
}
@@ -395,6 +404,7 @@ ssize_t vlc_stream_ReadPartial(stream_t *s, void *buf, size_t len)
if (ret >= 0)
{
priv->offset += ret;
+ assert(ret <= (ssize_t)len);
return ret;
}
@@ -403,6 +413,7 @@ ssize_t vlc_stream_ReadPartial(stream_t *s, void *buf, size_t len)
priv->offset += ret;
if (ret == 0)
priv->eof = len != 0;
+ assert(ret <= (ssize_t)len);
return ret;
}
@@ -420,6 +431,7 @@ ssize_t vlc_stream_Read(stream_t *s, void *buf, size_t len)
if (buf != NULL)
buf = (char *)buf + ret;
+ assert(len >= (size_t)ret);
len -= ret;
copied += ret;
}
More information about the vlc-commits
mailing list