Search
lxdream.org :: lxdream/src/gdrom/cdi.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/cdi.c
changeset 347:e686be8b10df
prev342:850502f0e8de
next422:61a0598e07ff
author nkeynes
date Sun Feb 04 11:30:41 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change Fix handling of (some?) v3.0 cdi files
file annotate diff log raw
1.1 --- a/src/gdrom/cdi.c Wed Jan 31 10:58:42 2007 +0000
1.2 +++ b/src/gdrom/cdi.c Sun Feb 04 11:30:41 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: cdi.c,v 1.5 2007-01-31 10:58:42 nkeynes Exp $
1.6 + * $Id: cdi.c,v 1.6 2007-02-04 11:30:41 nkeynes Exp $
1.7 *
1.8 * CDI CD-image file support
1.9 *
1.10 @@ -35,8 +35,9 @@
1.11 struct gdrom_image_class cdi_image_class = { "DiscJuggler", "cdi",
1.12 cdi_image_is_valid, cdi_image_open };
1.13
1.14 -static char track_start_marker[20] = { 0,0,1,0,0,0,255,255,255,255,
1.15 +static const char TRACK_START_MARKER[20] = { 0,0,1,0,0,0,255,255,255,255,
1.16 0,0,1,0,0,0,255,255,255,255 };
1.17 +static const char EXT_MARKER[9] = {0,255,255,255,255,255,255,255,255 };
1.18
1.19 struct cdi_trailer {
1.20 uint32_t cdi_version;
1.21 @@ -110,6 +111,11 @@
1.22
1.23 for( i=0; i< session_count; i++ ) {
1.24 fread( &track_count, sizeof(track_count), 1, f );
1.25 + if( track_count + total_tracks > 99 ) {
1.26 + ERROR( "Invalid number of tracks, bad cdi image\n" );
1.27 + disc->close(disc);
1.28 + return NULL;
1.29 + }
1.30 for( j=0; j<track_count; j++ ) {
1.31 struct cdi_track_data trk;
1.32 uint32_t new_fmt = 0;
1.33 @@ -119,7 +125,7 @@
1.34 fseek( f, 8, SEEK_CUR ); /* Skip */
1.35 }
1.36 fread( marker, 20, 1, f );
1.37 - if( memcmp( marker, track_start_marker, 20) != 0 ) {
1.38 + if( memcmp( marker, TRACK_START_MARKER, 20) != 0 ) {
1.39 ERROR( "Track start marker not found, error reading cdi image\n" );
1.40 disc->close(disc);
1.41 return NULL;
1.42 @@ -179,11 +185,11 @@
1.43 trk.pregap_length * image->track[total_tracks].sector_size ;
1.44 posn += trk.total_length * image->track[total_tracks].sector_size;
1.45 total_tracks++;
1.46 - lseek( fd, 12, SEEK_CUR );
1.47 - if( new_fmt ) {
1.48 - fseek( f, 90, SEEK_CUR );
1.49 + fread( marker, 1, 9, f );
1.50 + if( memcmp( marker, EXT_MARKER, 9 ) == 0 ) {
1.51 + fseek( f, 91, SEEK_CUR );
1.52 } else {
1.53 - fseek( f, 12, SEEK_CUR );
1.54 + fseek( f, 3, SEEK_CUR );
1.55 }
1.56 }
1.57 }
.