aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKarlson2k <k2k@narod.ru>2014-11-12 16:25:18 +0300
committerKarlson2k <k2k@narod.ru>2014-11-17 17:11:55 +0300
commitbc67f8c9e552d6440dc284d479c5c570e64f7fde (patch)
treef4565aa681251b294c4dcc069d232b4ea018dcce /lib
parent74089ce08a5b6a99bf19275187b9fb0375d819c7 (diff)
libdvdcss: better handle partial read in libc_read
Diffstat (limited to 'lib')
-rw-r--r--lib/libdvd/libdvdcss/src/device.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/libdvd/libdvdcss/src/device.c b/lib/libdvd/libdvdcss/src/device.c
index 3de18793be..53d1fdf64a 100644
--- a/lib/libdvd/libdvdcss/src/device.c
+++ b/lib/libdvd/libdvdcss/src/device.c
@@ -816,13 +816,21 @@ static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
off_t i_size, i_ret;
i_size = (off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE;
- i_ret = read( dvdcss->i_read_fd, p_buffer, i_size );
-
- if( i_ret < 0 )
+ i_ret = 0;
+ while( i_ret < i_size )
{
- print_error( dvdcss, "read error" );
- dvdcss->i_pos = -1;
- return i_ret;
+ off_t i_r;
+ i_r = read( dvdcss->i_read_fd, ((char*)p_buffer) + i_ret, i_size - i_ret );
+ if( i_r < 0 )
+ {
+ print_error(dvdcss, "read error");
+ dvdcss->i_pos = -1;
+ return i_r;
+ }
+ if( i_r == 0 )
+ break;
+
+ i_ret += i_r;
}
/* Handle partial reads */