<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>Am 09.06.2014 um 20:14 schrieb Rémi Denis-Courmont <<a href="mailto:remi@remlab.net">remi@remlab.net</a>>:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Le lundi 9 juin 2014, 19:56:18<span class="Apple-converted-space"> </span><a href="mailto:david.fuhrmann@gmail.com">david.fuhrmann@gmail.com</a><span class="Apple-converted-space"> </span>a écrit :<br><blockquote type="cite">From: David Fuhrmann <<a href="mailto:dfuhrmann@videolan.org">dfuhrmann@videolan.org</a>><br><br>The error case i_pos > tk->i_end implies that<br>p_sys->stream.i_offset > tk->i_end - tk->i_start. This is not allowed<br>as it leads to unsigned underflows in several places. Thus, i_offset<br>is set to a sane value.<br><br>The conversion to int in AStreamRefillStream is necessary to properly<br>detect i_toread < 0, and to avoid the mentioned underflow.<br></blockquote><br>I think you're better off eliminating any case that leads to this, because this<span class="Apple-converted-space"> </span><br>is ostensibly bogus.<br><br><blockquote type="cite"><br>close #11488<br>---<br>src/input/stream.c | 8 +++++---<br>1 file changed, 5 insertions(+), 3 deletions(-)<br><br>diff --git a/src/input/stream.c b/src/input/stream.c<br>index 18e77e2..eafc7a2 100644<br>--- a/src/input/stream.c<br>+++ b/src/input/stream.c<br>@@ -1261,8 +1261,10 @@ static int AStreamSeekStream( stream_t *s, uint64_t<br>i_pos ) if( p_sys->stream.i_used < STREAM_READ_ATONCE / 2 )<br>            p_sys->stream.i_used = STREAM_READ_ATONCE / 2;<br><br>-        if( AStreamRefillStream( s ) && i_pos >= tk->i_end )<br>+        if( AStreamRefillStream( s ) && i_pos >= tk->i_end ) {<br>+            p_sys->stream.i_offset = tk->i_end - tk->i_start;<br></blockquote><br>This looks fishy. RefillStream should never let i_offset point outside the buffer<span class="Apple-converted-space"> </span><br>to begin with.<br></div></blockquote><div><br></div><div>Hi,</div><div><br></div><div>In this situation, i_offset is alread pointing outside the buffer before AStreamRefillStream, see a couple of lines before (because i_pos > tk->i_end before the AStreamRefillStream call). Now, according to the the error check, I assumed that this might be temporarily acceptable, and then, AStreamRefillStream is called to read more data so that i_offset is valid again afterwards. The code looks like it was intended to support that.</div><div><br></div><div>If this is not intended, then indeed, the wrong i_offset should be corrected already before AStreamRefillStream. But in this case, AFAIU i_pos > tk->i_end should never be true in any way, thus the error check might be redundant.</div><div><br></div><div>With best regards,</div><div>David</div><blockquote type="cite"></blockquote></div><br></body></html>