<div dir="ltr">OK.<div>Is it acceptable? </div><div>Can't send by git send-email (not working on win32)</div><div><br></div><div><div>From d1f857ab8ab811a4d63907a8805ad42fea170bb1 Mon Sep 17 00:00:00 2001</div><div>From: Evgeny Grin <<a href="mailto:karlson2k@kodi.tv">karlson2k@kodi.tv</a>></div><div>Date: Tue, 18 Nov 2014 00:51:44 +0300</div><div>Subject: [PATCH 1/2] fix position after partial read in libc_read</div><div><br></div><div>---</div><div> src/device.c | 5 +++--</div><div> 1 file changed, 3 insertions(+), 2 deletions(-)</div><div><br></div><div>diff --git a/src/device.c b/src/device.c</div><div>index da4ecc4..94f448d 100644</div><div>--- a/src/device.c</div><div>+++ b/src/device.c</div><div>@@ -570,10 +570,11 @@ static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )</div><div> /* Handle partial reads */</div><div> if( i_ret != i_size )</div><div> {</div><div>- int i_seek;</div><div>+ int i_seek, i_set_pos;</div><div> </div><div>+ i_set_pos = dvdcss->i_pos + i_ret_blocks;</div><div> dvdcss->i_pos = -1;</div><div>- i_seek = libc_seek( dvdcss, i_ret_blocks );</div><div>+ i_seek = libc_seek( dvdcss, i_set_pos );</div><div> if( i_seek < 0 )</div><div> {</div><div> return i_seek;</div><div>-- </div><div>2.1.0.9738.g8768113</div><div><br></div></div><div><br></div><div><div>From e68bdef901ce2c7f52f0912edb822d3e3a1c8c6d Mon Sep 17 00:00:00 2001</div><div>From: Evgeny Grin <<a href="mailto:karlson2k@kodi.tv">karlson2k@kodi.tv</a>></div><div>Date: Tue, 18 Nov 2014 01:09:12 +0300</div><div>Subject: [PATCH 2/2] better handle partial read in libc_read</div><div><br></div><div>---</div><div> src/device.c | 20 +++++++++++++++-----</div><div> 1 file changed, 15 insertions(+), 5 deletions(-)</div><div><br></div><div>diff --git a/src/device.c b/src/device.c</div><div>index 94f448d..ef26768 100644</div><div>--- a/src/device.c</div><div>+++ b/src/device.c</div><div>@@ -556,13 +556,23 @@ static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )</div><div> ssize_t i_size, i_ret, i_ret_blocks;</div><div> </div><div> i_size = i_blocks * DVDCSS_BLOCK_SIZE;</div><div>- i_ret = read( dvdcss->i_fd, p_buffer, i_size );</div><div>+ i_ret = 0;</div><div> </div><div>- if( i_ret < 0 )</div><div>+ while( i_ret < i_size )</div><div> {</div><div>- print_error( dvdcss, "read error" );</div><div>- dvdcss->i_pos = -1;</div><div>- return i_ret;</div><div>+ ssize_t i_r;</div><div>+</div><div>+ i_r = read( dvdcss->i_read_fd, ((char*)p_buffer) + i_ret, i_size - i_ret );</div><div>+ if( i_r < 0 )</div><div>+ {</div><div>+ print_error( dvdcss, "read error" );</div><div>+ dvdcss->i_pos = -1;</div><div>+ return i_r;</div><div>+ }</div><div>+ if( i_r == 0 )</div><div>+ break;</div><div>+</div><div>+ i_ret += i_r;</div><div> }</div><div> </div><div> i_ret_blocks = i_ret / DVDCSS_BLOCK_SIZE;</div><div>-- </div><div>2.1.0.9738.g8768113</div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 18 November 2014 01:34, Diego Biurrun <span dir="ltr"><<a href="mailto:diego@biurrun.de" target="_blank">diego@biurrun.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">These are not the type of Git patch we are looking for. Properly commit<br>
your changes and use git-format-patch or git-send-email please, not just<br>
git-diff.<br>
<div class="HOEnZb"><div class="h5"><br>
On Tue, Nov 18, 2014 at 01:22:11AM +0300, Evgeny Grin wrote:<br>
> No problem:<br>
><br>
> fix position after partial read in libc_read<br>
><br>
> diff --git a/src/device.c b/src/device.c<br>
> index da4ecc4..94f448d 100644<br>
> --- a/src/device.c<br>
> +++ b/src/device.c<br>
> @@ -570,10 +570,11 @@ static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )<br>
> /* Handle partial reads */<br>
> if( i_ret != i_size )<br>
> {<br>
> - int i_seek;<br>
> + int i_seek, i_set_pos;<br>
><br>
> + i_set_pos = dvdcss->i_pos + i_ret_blocks;<br>
> dvdcss->i_pos = -1;<br>
> - i_seek = libc_seek( dvdcss, i_ret_blocks );<br>
> + i_seek = libc_seek( dvdcss, i_set_pos );<br>
> if( i_seek < 0 )<br>
> {<br>
> return i_seek;<br>
><br>
> fix position after partial read in libc_read<br>
><br>
> diff --git a/src/device.c b/src/device.c<br>
> index 94f448d..ef26768 100644<br>
> --- a/src/device.c<br>
> +++ b/src/device.c<br>
> @@ -556,13 +556,23 @@ static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )<br>
> ssize_t i_size, i_ret, i_ret_blocks;<br>
><br>
> i_size = i_blocks * DVDCSS_BLOCK_SIZE;<br>
> - i_ret = read( dvdcss->i_fd, p_buffer, i_size );<br>
> + i_ret = 0;<br>
><br>
> - if( i_ret < 0 )<br>
> + while( i_ret < i_size )<br>
> {<br>
> - print_error( dvdcss, "read error" );<br>
> - dvdcss->i_pos = -1;<br>
> - return i_ret;<br>
> + ssize_t i_r;<br>
> +<br>
> + i_r = read( dvdcss->i_read_fd, ((char*)p_buffer) + i_ret, i_size - i_ret );<br>
> + if( i_r < 0 )<br>
> + {<br>
> + print_error( dvdcss, "read error" );<br>
> + dvdcss->i_pos = -1;<br>
> + return i_r;<br>
> + }<br>
> + if( i_r == 0 )<br>
> + break;<br>
> +<br>
> + i_ret += i_r;<br>
> }<br>
><br>
> i_ret_blocks = i_ret / DVDCSS_BLOCK_SIZE;<br>
><br>
> 18.11.2014, 00:04, "Diego Biurrun" <<a href="mailto:diego@biurrun.de">diego@biurrun.de</a>>:<br>
> > On Mon, Nov 17, 2014 at 11:42:43PM +0300, Evgeny Grin wrote:<br>
> >> Here are the patches (made for 1.2.13, but applicable for latest git master):<br>
> > Please use Git to create patches, thank you.<br>
> ><br>
> > Diego<br>
> > _______________________________________________<br>
> > libdvdcss-devel mailing list<br>
> > <a href="mailto:libdvdcss-devel@videolan.org">libdvdcss-devel@videolan.org</a><br>
> > <a href="https://mailman.videolan.org/listinfo/libdvdcss-devel" target="_blank">https://mailman.videolan.org/listinfo/libdvdcss-devel</a><br>
> -------- Завершение пересылаемого сообщения --------<br>
><br>
> -- <br>
> Best Wishes,<br>
> Evgeny Grin<br>
> _______________________________________________<br>
> libdvdcss-devel mailing list<br>
> <a href="mailto:libdvdcss-devel@videolan.org">libdvdcss-devel@videolan.org</a><br>
> <a href="https://mailman.videolan.org/listinfo/libdvdcss-devel" target="_blank">https://mailman.videolan.org/listinfo/libdvdcss-devel</a><br>
_______________________________________________<br>
libdvdcss-devel mailing list<br>
<a href="mailto:libdvdcss-devel@videolan.org">libdvdcss-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/libdvdcss-devel" target="_blank">https://mailman.videolan.org/listinfo/libdvdcss-devel</a><br>
</div></div></blockquote></div><br></div>