Skip to content

Commit

Permalink
Merge pull request xbmc#5815 from Memphiz/fixisocrash2
Browse files Browse the repository at this point in the history
[libdvdread] - fix partial read in file_read
  • Loading branch information
topfs2 committed Nov 26, 2014
2 parents 68a0ce0 + 874a69c commit 67971bd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/libdvd/libdvdread/src/dvd_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,14 @@ static int file_read(dvd_input_t dev, void *buffer, int blocks, int flags)
{
size_t len;
ssize_t ret;
char *buf;

buf = (char*) buffer;
len = (size_t)blocks * DVD_VIDEO_LB_LEN;

while(len > 0) {

ret = read(dev->fd, buffer, len);
ret = read(dev->fd, buf, len);

if(ret < 0) {
/* One of the reads failed, too bad. We won't even bother
Expand All @@ -241,6 +243,7 @@ static int file_read(dvd_input_t dev, void *buffer, int blocks, int flags)
return (int) (bytes / DVD_VIDEO_LB_LEN);
}

buf += ret;
len -= ret;
}

Expand Down
30 changes: 30 additions & 0 deletions lib/libdvd/patches/07-libdvdread-fix-partial-read.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
see upstream patch here https://mailman.videolan.org/pipermail/libdvdnav-devel/2014-November/000346.html

diff --git a/lib/libdvd/libdvdread/src/dvd_input.c b/lib/libdvd/libdvdread/src/dvd_input.c
index 4a02524..7efff01 100644
--- a/lib/libdvd/libdvdread/src/dvd_input.c
+++ b/lib/libdvd/libdvdread/src/dvd_input.c
@@ -217,12 +217,14 @@ static int file_read(dvd_input_t dev, void *buffer, int blocks, int flags)
{
size_t len;
ssize_t ret;
+ char *buf;

+ buf = (char*) buffer;
len = (size_t)blocks * DVD_VIDEO_LB_LEN;

while(len > 0) {

- ret = read(dev->fd, buffer, len);
+ ret = read(dev->fd, buf, len);

if(ret < 0) {
/* One of the reads failed, too bad. We won't even bother
@@ -241,6 +243,7 @@ static int file_read(dvd_input_t dev, void *buffer, int blocks, int flags)
return (int) (bytes / DVD_VIDEO_LB_LEN);
}

+ buf += ret;
len -= ret;
}

0 comments on commit 67971bd

Please sign in to comment.