dvd_udf.c UDFScanDir fix

Billy Biggs vektor at dumbterm.net
Mon Apr 9 17:10:30 CEST 2001


  Hi all,

  There is a bug in the convergence UDF code in UDFScanDir.  It assumes
that directory entries end on a sector boundary, which isn't the case at
least for the Ghostbusters DVD.

  Here is my fixed implementation.  I know that xine, oms, and videolan
all have copies of this code in their CVS, so patching is required.

  The fixed code below reads in two blocks at a time to avoid malloc().

==
int UDFScanDir( int fd, struct AD Dir, char *FileName, struct AD
                *FileICB )
{
    char filename[ MAX_UDF_FILE_NAME_LEN ];
    u8 directory[ 2 * DVD_VIDEO_LB_LEN ];
    u32 lbnum;
    u16 TagID;
    u8 filechar;
    int p;

    /* Scan dir for ICB of file */
    lbnum = partition.Start + Dir.Location;

    if( UDFReadLB( fd, lbnum, 2, directory ) <= 0 ) {
        return 0;
    }

    p = 0;
    while( p < Dir.Length ) {
        if( p > DVD_VIDEO_LB_LEN ) {
            ++lbnum;
            p -= DVD_VIDEO_LB_LEN;
            Dir.Length -= DVD_VIDEO_LB_LEN;
            if( UDFReadLB( fd, lbnum, 2, directory ) <= 0 ) {
                return 0;
            }
        }
        UDFDescriptor( &directory[ p ], &TagID );
        if( TagID == 257 ) {
            p += UDFFileIdentifier( &directory[ p ], &filechar,
                                    filename, FileICB );
            if( !strcasecmp( FileName, filename ) ) {
                return 1;
            }
        } else {
            return 0;
        }
    }

    return 0;
}

-- 
Billy Biggs                     bbiggs at dumbterm.net
http://www.billybiggs.com/      wbiggs at uwaterloo.ca




More information about the vlc-devel mailing list