Mercurial > libdvdread4.hg
comparison dvd_udf.c @ 72:99af5ed114a4 src
Fix segfault when reading certain DVDs, for example "Thor".
This results from a new anti-copy scheme where the real video_ts.ifo
is hidden. Use of the decoy video_ts.ifo results in a unplayable DVD.
Patch by Alexander Roalter \alex!roalter*it/.
Verified by John Stebbins |stebbins%jethaddev&com|.
author | rathann |
---|---|
date | Thu, 06 Oct 2011 12:10:01 +0000 |
parents | 3bc841283972 |
children | 1b8797855771 |
comparison
equal
deleted
inserted
replaced
71:df32da8e44b1 | 72:99af5ed114a4 |
---|---|
327 #define GETN(p, n, target) memcpy(target, &data[p], n) | 327 #define GETN(p, n, target) memcpy(target, &data[p], n) |
328 | 328 |
329 static int Unicodedecode( uint8_t *data, int len, char *target ) | 329 static int Unicodedecode( uint8_t *data, int len, char *target ) |
330 { | 330 { |
331 int p = 1, i = 0; | 331 int p = 1, i = 0; |
332 int err = 0; | |
332 | 333 |
333 if( ( data[ 0 ] == 8 ) || ( data[ 0 ] == 16 ) ) do { | 334 if( ( data[ 0 ] == 8 ) || ( data[ 0 ] == 16 ) ) do { |
334 if( data[ 0 ] == 16 ) p++; /* Ignore MSB of unicode16 */ | 335 if( data[ 0 ] == 16 ) err |= data[p++]; /* character cannot be converted to 8bit, return error */ |
335 if( p < len ) { | 336 if( p < len ) { |
336 target[ i++ ] = data[ p++ ]; | 337 target[ i++ ] = data[ p++ ]; |
337 } | 338 } |
338 } while( p < len ); | 339 } while( p < len ); |
339 | 340 |
340 target[ i ] = '\0'; | 341 target[ i ] = '\0'; |
341 return 0; | 342 return !err; |
342 } | 343 } |
343 | 344 |
344 static int UDFDescriptor( uint8_t *data, uint16_t *TagID ) | 345 static int UDFDescriptor( uint8_t *data, uint16_t *TagID ) |
345 { | 346 { |
346 *TagID = GETN2(0); | 347 *TagID = GETN2(0); |
488 | 489 |
489 *FileCharacteristics = GETN1(18); | 490 *FileCharacteristics = GETN1(18); |
490 L_FI = GETN1(19); | 491 L_FI = GETN1(19); |
491 UDFLongAD(&data[20], FileICB); | 492 UDFLongAD(&data[20], FileICB); |
492 L_IU = GETN2(36); | 493 L_IU = GETN2(36); |
493 if (L_FI) Unicodedecode(&data[38 + L_IU], L_FI, FileName); | 494 if (L_FI) { |
494 else FileName[0] = '\0'; | 495 if (!Unicodedecode(&data[38 + L_IU], L_FI, FileName)) FileName[0] = 0; |
496 } else FileName[0] = '\0'; | |
495 return 4 * ((38 + L_FI + L_IU + 3) / 4); | 497 return 4 * ((38 + L_FI + L_IU + 3) / 4); |
496 } | 498 } |
497 | 499 |
498 /** | 500 /** |
499 * Maps ICB to FileAD | 501 * Maps ICB to FileAD |