flac/foreign_metadata: Fix for odd RIFF chunk size
authorErik de Castro Lopo <erikd@mega-nerd.com>
Fri, 10 Jul 2015 09:20:24 +0000 (19:20 +1000)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Fri, 10 Jul 2015 09:22:39 +0000 (19:22 +1000)
Accept odd values to ckSize of RIFF chunk. FLAC should read these
but should avoid creating them.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
Closes: https://sourceforge.net/p/flac/support-requests/152/
Closes: https://sourceforge.net/p/flac/bugs/419/

src/flac/foreign_metadata.c

index 8afe694..d01f466 100644 (file)
@@ -198,8 +198,11 @@ static FLAC__bool read_from_wave_(foreign_metadata_t *fm, FILE *f, const char **
        }
        if(!append_block_(fm, offset, 12, error))
                return false;
-       if(!fm->is_rf64 || unpack32le_(buffer+4) != 0xffffffffu)
+       if(!fm->is_rf64 || unpack32le_(buffer+4) != 0xffffffffu) {
                eof_offset = (FLAC__off_t)8 + (FLAC__off_t)unpack32le_(buffer+4);
+               if(eof_offset & 1) /* fix odd RIFF size */
+                       eof_offset++;
+       }
        while(!feof(f)) {
                FLAC__uint32 size;
                if((offset = ftello(f)) < 0) {