Blame SOURCES/A01-UDFReadBlocks-errors.patch

67959c
diff --git a/src/dvd_reader.c b/src/dvd_reader.c
67959c
index 4e112d3..e8d50f3 100644
67959c
--- a/src/dvd_reader.c
67959c
+++ b/src/dvd_reader.c
67959c
@@ -1156,13 +1156,13 @@ int InternalUDFReadBlocksRaw( const dvd_reader_t *device, uint32_t lb_number,
67959c
 
67959c
   if( !device->dev ) {
67959c
     fprintf( stderr, "libdvdread: Fatal error in block read.\n" );
67959c
-    return 0;
67959c
+    return -1;
67959c
   }
67959c
 
67959c
   ret = dvdinput_seek( device->dev, (int) lb_number );
67959c
   if( ret != (int) lb_number ) {
67959c
     fprintf( stderr, "libdvdread: Can't seek to block %u\n", lb_number );
67959c
-    return 0;
67959c
+    return ret;
67959c
   }
67959c
 
67959c
   ret = dvdinput_read( device->dev, (char *) data,
67959c
diff --git a/src/dvd_udf.c b/src/dvd_udf.c
67959c
index 5eb3d2b..68c3a9a 100644
67959c
--- a/src/dvd_udf.c
67959c
+++ b/src/dvd_udf.c
67959c
@@ -516,6 +516,7 @@ static int UDFMapICB( dvd_reader_t *device, struct AD ICB, uint8_t *FileType,
67959c
   uint32_t lbnum;
67959c
   uint16_t TagID;
67959c
   struct icbmap tmpmap;
67959c
+  int ret;
67959c
 
67959c
   lbnum = partition->Start + ICB.Location;
67959c
   tmpmap.lbn = lbnum;
67959c
@@ -526,10 +527,16 @@ static int UDFMapICB( dvd_reader_t *device, struct AD ICB, uint8_t *FileType,
67959c
   }
67959c
 
67959c
   do {
67959c
-    if( DVDReadLBUDF( device, lbnum++, 1, LogBlock, 0 ) <= 0 )
67959c
+    ret = DVDReadLBUDF( device, lbnum++, 1, LogBlock, 0 );
67959c
+    if( ret < 0 ) {
67959c
+      return ret;
67959c
+    }
67959c
+    else if( ret == 0 ) {
67959c
       TagID = 0;
67959c
-    else
67959c
+    }
67959c
+    else {
67959c
       UDFDescriptor( LogBlock, &TagID );
67959c
+    }
67959c
 
67959c
     if( TagID == FileEntry ) {
67959c
       UDFFileEntry( LogBlock, FileType, partition, File );
67959c
@@ -677,6 +688,7 @@ static int UDFGetAVDP( dvd_reader_t *device,
67959c
   uint32_t lastsector;
67959c
   int terminate;
67959c
   struct avdp_t;
67959c
+  int ret;
67959c
 
67959c
   if(GetUDFCache(device, AVDPCache, 0, avdp))
67959c
     return 1;
67959c
@@ -687,11 +699,16 @@ static int UDFGetAVDP( dvd_reader_t *device,
67959c
   terminate = 0;
67959c
 
67959c
   for(;;) {
67959c
-    if( DVDReadLBUDF( device, lbnum, 1, Anchor, 0 ) > 0 ) {
67959c
-      UDFDescriptor( Anchor, &TagID );
67959c
-    } else {
67959c
+    ret = DVDReadLBUDF( device, lbnum, 1, Anchor, 0 );
67959c
+    if( ret < 0 ) {
67959c
+      return ret;
67959c
+    }
67959c
+    else if( ret == 0 ) {
67959c
       TagID = 0;
67959c
     }
67959c
+    else {
67959c
+      UDFDescriptor( Anchor, &TagID );
67959c
+    }
67959c
     if (TagID != AnchorVolumeDescriptorPointer) {
67959c
       /* Not an anchor */
67959c
       if( terminate ) return 0; /* Final try failed */
67959c
@@ -742,7 +759,7 @@ static int UDFFindPartition( dvd_reader_t *device, int partnum,
67959c
   uint8_t *LogBlock = (uint8_t *)(((uintptr_t)LogBlock_base & ~((uintptr_t)2047)) + 2048);
67959c
   uint32_t lbnum, MVDS_location, MVDS_length;
67959c
   uint16_t TagID;
67959c
-  int i, volvalid;
67959c
+  int i, volvalid, ret;
67959c
   struct avdp_t avdp;
67959c
 
67959c
   if(!UDFGetAVDP(device, &avdp))
67959c
@@ -761,10 +778,16 @@ static int UDFFindPartition( dvd_reader_t *device, int partnum,
67959c
     lbnum = MVDS_location;
67959c
     do {
67959c
 
67959c
-      if( DVDReadLBUDF( device, lbnum++, 1, LogBlock, 0 ) <= 0 )
67959c
+      ret = DVDReadLBUDF( device, lbnum++, 1, LogBlock, 0 );
67959c
+      if( ret < 0 ) {
67959c
+        return ret;
67959c
+      }
67959c
+      else if( ret == 0 ) {
67959c
         TagID = 0;
67959c
-      else
67959c
+      }
67959c
+      else {
67959c
         UDFDescriptor( LogBlock, &TagID );
67959c
+      }
67959c
 
67959c
       if( ( TagID == PartitionDescriptor ) && ( !part->valid ) ) {
67959c
         /* Partition Descriptor */
67959c
@@ -805,6 +828,7 @@ uint32_t UDFFindFile( dvd_reader_t *device, const char *filename,
67959c
   struct AD RootICB, File, ICB;
67959c
   char tokenline[ MAX_UDF_FILE_NAME_LEN ];
67959c
   uint8_t filetype;
67959c
+  int ret;
67959c
 
67959c
   *filesize = 0;
67959c
   tokenline[0] = '\0';
67959c
@@ -820,10 +844,16 @@ uint32_t UDFFindFile( dvd_reader_t *device, const char *filename,
67959c
     /* Find root dir ICB */
67959c
     lbnum = partition.Start;
67959c
     do {
67959c
-      if( DVDReadLBUDF( device, lbnum++, 1, LogBlock, 0 ) <= 0 )
67959c
+      ret = DVDReadLBUDF( device, lbnum++, 1, LogBlock, 0 );
67959c
+      if( ret < 0 ) {
67959c
+        return ret;
67959c
+      }
67959c
+      else if( ret == 0 ) {
67959c
         TagID = 0;
67959c
-      else
67959c
+      }
67959c
+      else {
67959c
         UDFDescriptor( LogBlock, &TagID );
67959c
+      }
67959c
 
67959c
       /* File Set Descriptor */
67959c
       if( TagID == FileSetDescriptor )  /* File Set Descriptor */
67959c
@@ -886,7 +916,7 @@ static int UDFGetDescriptor( dvd_reader_t *device, int id,
67959c
   uint32_t lbnum, MVDS_location, MVDS_length;
67959c
   struct avdp_t avdp;
67959c
   uint16_t TagID;
67959c
-  int i, desc_found = 0;
67959c
+  int i, desc_found = 0, ret;
67959c
   /* Find Anchor */
67959c
   lbnum = 256;   /* Try #1, prime anchor */
67959c
   if(bufsize < DVD_VIDEO_LB_LEN)
67959c
@@ -904,10 +934,16 @@ static int UDFGetDescriptor( dvd_reader_t *device, int id,
67959c
     /* Find  Descriptor */
67959c
     lbnum = MVDS_location;
67959c
     do {
67959c
-      if( DVDReadLBUDF( device, lbnum++, 1, descriptor, 0 ) <= 0 )
67959c
+      ret = DVDReadLBUDF( device, lbnum++, 1, descriptor, 0 );
67959c
+      if( ret < 0 ) {
67959c
+        return ret;
67959c
+      }
67959c
+      else if( ret == 0 ) {
67959c
         TagID = 0;
67959c
-      else
67959c
+      }
67959c
+      else {
67959c
         UDFDescriptor( descriptor, &TagID );
67959c
+      }
67959c
       if( (TagID == id) && ( !desc_found ) )
67959c
         /* Descriptor */
67959c
         desc_found = 1;