@@ -28,6 +28,9 @@ static VIDEO_EME_CENC_MP4: &str = "tests/bipbop_480wp_1001kbps-cenc-video-key1-i
28
28
static AUDIO_EME_CBCS_MP4 : & str = "tests/bipbop_cbcs_audio_init.mp4" ;
29
29
static VIDEO_EME_CBCS_MP4 : & str = "tests/bipbop_cbcs_video_init.mp4" ;
30
30
static VIDEO_AV1_MP4 : & str = "tests/tiny_av1.mp4" ;
31
+ // This file contains invalid userdata in its copyright userdata. See
32
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1687357 for more information.
33
+ static VIDEO_INVALID_USERDATA : & str = "tests/invalid_userdata.mp4" ;
31
34
static IMAGE_AVIF : & str = "av1-avif/testFiles/Microsoft/Monochrome.avif" ;
32
35
static IMAGE_AVIF_EXTENTS : & str = "tests/kodim-extents.avif" ;
33
36
static IMAGE_AVIF_ALPHA : & str = "tests/bug-1661347.avif" ;
@@ -291,6 +294,46 @@ fn public_metadata_gnre() {
291
294
assert_eq ! ( u32 :: from_le_bytes( bytes) , 0x00ff_d8ff ) ;
292
295
}
293
296
297
+ #[ test]
298
+ fn public_invalid_metadata ( ) {
299
+ // Test that reading userdata containing invalid metadata is not fatal to parsing and that
300
+ // expected values are still found.
301
+ let mut fd = File :: open ( VIDEO_INVALID_USERDATA ) . expect ( "Unknown file" ) ;
302
+ let mut buf = Vec :: new ( ) ;
303
+ fd. read_to_end ( & mut buf) . expect ( "File error" ) ;
304
+
305
+ let mut c = Cursor :: new ( & buf) ;
306
+ let context = mp4:: read_mp4 ( & mut c) . expect ( "read_mp4 failed" ) ;
307
+ // Should have userdata.
308
+ assert ! ( context. userdata. is_some( ) ) ;
309
+ // But it should contain an error.
310
+ assert ! ( context. userdata. unwrap( ) . is_err( ) ) ;
311
+ // Smoke test that other data has been parsed. Don't check everything, just make sure some
312
+ // values are as expected.
313
+ assert_eq ! ( context. tracks. len( ) , 2 ) ;
314
+ for track in context. tracks {
315
+ match track. track_type {
316
+ mp4:: TrackType :: Video => {
317
+ // Check some of the values in the video tkhd.
318
+ let tkhd = track. tkhd . unwrap ( ) ;
319
+ assert_eq ! ( tkhd. disabled, false ) ;
320
+ assert_eq ! ( tkhd. duration, 231232 ) ;
321
+ assert_eq ! ( tkhd. width, 83_886_080 ) ;
322
+ assert_eq ! ( tkhd. height, 47_185_920 ) ;
323
+ }
324
+ mp4:: TrackType :: Audio => {
325
+ // Check some of the values in the audio tkhd.
326
+ let tkhd = track. tkhd . unwrap ( ) ;
327
+ assert_eq ! ( tkhd. disabled, false ) ;
328
+ assert_eq ! ( tkhd. duration, 231338 ) ;
329
+ assert_eq ! ( tkhd. width, 0 ) ;
330
+ assert_eq ! ( tkhd. height, 0 ) ;
331
+ }
332
+ _ => panic ! ( "File should not contain other tracks." )
333
+ }
334
+ }
335
+ }
336
+
294
337
#[ test]
295
338
fn public_audio_tenc ( ) {
296
339
let kid = vec ! [
0 commit comments