Bugzilla – Bug 16171
Audio::Scan - Incorrect "bad picture block" on valid flac file
Last modified: 2011-05-18 15:29:32 UTC
Created attachment 6813 [details] Truncated flac file as a test case A valid flac file is being reported as "Invalid FLAC file: [filename], bad picture block". Steps to reproduce: 1. See attached flac file - waves-test.flac. This file is the first 392KB of a flac file containing the metadata block. The metadata block will parse fine with "metaflac --list" 2. perl -I/usr/share/squeezeboxserver/CPAN -I/usr/share/squeezeboxserver/CPAN/arch/5.8/x86_64-linux-thread-multi -MAudio::Scan -e 'Audio::Scan->scan("waves-test.flac");' Invalid FLAC file: waves-test.flac, bad picture block This manifests itself with Audio::Scan versions 0.62 and also 0.79. Output in debug mode shows: Buffer allocated with 4096 bytes Buffering from file @ 0 (min_wanted 10, max_wanted 4096, adjusted to 4096) Buffered 4096 bytes, new pos 4096 Parsing metadata block, type 0, len 34, done 0 Parsing metadata block, type 3, len 3726, done 0 not seeking, skipping seektable Parsing metadata block, type 4, len 301, done 0 Parsing metadata block, type 6, len 165575, done 0 mime_length: 9 ---> Returns NULL here Suggested patch: ------ --- Audio-Scan-0.79/src/common.c.orig 2010-04-30 09:03:07.000000000 +1000 +++ Audio-Scan-0.79/src/common.c 2010-04-30 09:03:07.000000000 +1000 @@ -286,9 +286,6 @@ mime_length = buffer_get_int(buf); DEBUG_TRACE(" mime_length: %d\n", mime_length); - if (mime_length > buffer_len(buf)) { - return NULL; - } // Check we have enough for mime_type and desc_length if ( !_check_buf(infile, buf, mime_length + 4, DEFAULT_BLOCK_SIZE) ) { @@ -300,9 +297,6 @@ desc_length = buffer_get_int(buf); DEBUG_TRACE(" desc_length: %d\n", mime_length); - if (desc_length > buffer_len(buf)) { - return NULL; - } // Check we have enough for desc_length, width, height, depth, color_index, pic_length if ( !_check_buf(infile, buf, desc_length + 20, DEFAULT_BLOCK_SIZE) ) { ------
This bug was seen there too, with 7 files in a 7.000 tracks collection: Invalid FLAC file: /espace/SB/m/CLASSIC EB/De Larrocha, Alicia/Mendelssohn Romances sans paroles, Chopin Polonaise-Fantaisie - De Larrocha - RCA/01 Song without words for piano no. 1 in e major, op. 19b1.flac, bad picture block Invalid FLAC file: /espace/SB/m/CD EBVR/Badly Drawn Boy/2000 The Hour Of Bewilderbeast/08 Body Rap.flac, bad picture block Use of uninitialized value in hash element at ./md5scan.pl line 40. Use of uninitialized value in hash element at ./md5scan.pl line 42. Use of uninitialized value in concatenation (.) or string at ./md5scan.pl line 42. Invalid FLAC file: /espace/SB/m/CD EBVR/Alain Bashung/1991 Osez Joséphine/08 - Kalabougie.flac, bad picture block Use of uninitialized value in hash element at ./md5scan.pl line 40. Use of uninitialized value in hash element at ./md5scan.pl line 42. Use of uninitialized value in concatenation (.) or string at ./md5scan.pl line 42. Invalid FLAC file: /espace/SB/m/CD EBVR/Alain Bashung/1998 Fantaisie Militaire/03 - Fantaisie Militaire.flac, bad picture block ... Test was made on a linux box with a brand new Audio::Scan from cpan: cpan[2]> i Audio::Scan CPAN: Storable loaded ok (v2.18) Going to read /root/.cpan/Metadata Database was generated on Wed, 01 Sep 2010 17:31:19 GMT Strange distribution name [Audio::Scan] Module id = Audio::Scan CPAN_USERID AGRUNDMA (Andy Grundman <andy@hXXXidized.org>) CPAN_VERSION 0.84 CPAN_FILE A/AG/AGRUNDMA/Audio-Scan-0.84.tar.gz UPLOAD_DATE 2010-08-27 MANPAGE Audio::Scan - Fast C metadata and tag reader for all common audio file formats INST_FILE /usr/local/lib/perl/5.10.0/Audio/Scan.pm INST_VERSION 0.84 Linux sun 2.6.30-bpo.1-686 #1 SMP Mon Aug 17 14:57:26 UTC 2009 i686 GNU/Linux
Thanks for your detailed bug report! This is actually already fixed in 0.85 (SBS 7.6).
Closing due to fix