diff options
author | Karlson2k <k2k@narod.ru> | 2014-11-12 16:25:18 +0300 |
---|---|---|
committer | Karlson2k <k2k@narod.ru> | 2014-11-17 17:11:55 +0300 |
commit | bc67f8c9e552d6440dc284d479c5c570e64f7fde (patch) | |
tree | f4565aa681251b294c4dcc069d232b4ea018dcce /lib | |
parent | 74089ce08a5b6a99bf19275187b9fb0375d819c7 (diff) |
libdvdcss: better handle partial read in libc_read
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libdvd/libdvdcss/src/device.c | 20 |
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 */ |