From ce6f8c419a3b6f81d9045a5cf36f625c8a229405 Mon Sep 17 00:00:00 2001 From: Rok Mandeljc Date: Sun, 24 Feb 2013 23:46:48 +0100 Subject: [PATCH] libMirage: READCD Parser: readcd from cdrtools appears to pad odd TOC lengths to make them even, whereas readcd from cdrkit does not. Make the .toc validation take this into account. --- libmirage/src/parsers/image-readcd/image-readcd-parser.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libmirage/src/parsers/image-readcd/image-readcd-parser.c b/libmirage/src/parsers/image-readcd/image-readcd-parser.c index 9b8a76b..68dc820 100644 --- a/libmirage/src/parsers/image-readcd/image-readcd-parser.c +++ b/libmirage/src/parsers/image-readcd/image-readcd-parser.c @@ -55,7 +55,6 @@ static gboolean mirage_parser_readcd_is_file_valid (MirageParserReadcd *self, GI return FALSE; } - /* First 4 bytes of TOC are its header; and first 2 bytes of that indicate the length */ g_seekable_seek(G_SEEKABLE(stream), 0, G_SEEK_SET, NULL, NULL); @@ -70,7 +69,10 @@ static gboolean mirage_parser_readcd_is_file_valid (MirageParserReadcd *self, GI g_seekable_seek(G_SEEKABLE(stream), 0, G_SEEK_END, NULL, NULL); file_size = g_seekable_tell(G_SEEKABLE(stream)); - if (file_size - 2 == toc_len + 2) { + /* readcd from cdrdtools appears to pad odd TOC lengths to make them + even, whereas readcd from cdrkit does not. So we account for both + cases. */ + if ((file_size == 2 + toc_len + 2) || (file_size == 2 + toc_len + 3)) { return TRUE; } -- 1.7.10.4