vlc | branch: master | Francois Cartegnie <fcvlc...@free.fr> | Thu Dec 5 16:14:04 2013 +0100| [3fdb19ce1b57cb2964567082cda81eee5082de34] | committer: Francois Cartegnie
access: rar: skip old volume format string on failure (fix #9835) > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3fdb19ce1b57cb2964567082cda81eee5082de34 --- modules/access/rar/access.c | 10 +++++++--- modules/access/rar/rar.c | 20 ++++++++++++-------- modules/access/rar/rar.h | 2 +- modules/access/rar/stream.c | 4 +++- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/modules/access/rar/access.c b/modules/access/rar/access.c index 49faeab..ddba8f2 100644 --- a/modules/access/rar/access.c +++ b/modules/access/rar/access.c @@ -156,10 +156,14 @@ int RarAccessOpen(vlc_object_t *object) stream_t *s = stream_UrlNew(access, base); if (!s) goto error; - int count; + int count = 0; rar_file_t **files; - if (RarProbe(s) || RarParse(s, &count, &files) || count <= 0) - goto error; + if ( RarProbe(s) || ( + RarParse(s, &count, &files, false ) && + RarParse(s, &count, &files, true ) + ) || + count <= 0 ) + goto error; rar_file_t *file = NULL; for (int i = 0; i < count; i++) { if (!file && !strcmp(files[i]->name, name)) diff --git a/modules/access/rar/rar.c b/modules/access/rar/rar.c index f368245..55afd21 100644 --- a/modules/access/rar/rar.c +++ b/modules/access/rar/rar.c @@ -281,16 +281,16 @@ typedef struct { const char *format; int start; int stop; + bool b_extonly; } rar_pattern_t; -static const rar_pattern_t *FindVolumePattern(const char *location) +static const rar_pattern_t *FindVolumePattern(const char *location, bool b_extonly ) { static const rar_pattern_t patterns[] = { - { ".part1.rar", "%s.part%.1d.rar", 2, 9 }, - { ".part01.rar", "%s.part%.2d.rar", 2, 99, }, - { ".part001.rar", "%s.part%.3d.rar", 2, 999 }, - { ".rar", "%s.%c%.2d", 0, 999 }, - { NULL, NULL, 0, 0 }, + { ".part01.rar", "%s.part%.2d.rar", 2, 99, false }, // new naming + { ".part001.rar", "%s.part%.3d.rar", 2, 999, false }, // new + { ".rar", "%s.%c%.2d", 0, 999, true }, // old + { NULL, NULL, 0, 0, false }, }; const size_t location_size = strlen(location); @@ -299,18 +299,22 @@ static const rar_pattern_t *FindVolumePattern(const char *location) if (location_size < match_size) continue; + + if ( b_extonly && !patterns[i].b_extonly ) + continue; + if (!strcmp(&location[location_size - match_size], patterns[i].match)) return &patterns[i]; } return NULL; } -int RarParse(stream_t *s, int *count, rar_file_t ***file) +int RarParse(stream_t *s, int *count, rar_file_t ***file, bool b_extonly) { *count = 0; *file = NULL; - const rar_pattern_t *pattern = FindVolumePattern(s->psz_path); + const rar_pattern_t *pattern = FindVolumePattern(s->psz_path, b_extonly); int volume_offset = 0; char *volume_mrl; diff --git a/modules/access/rar/rar.h b/modules/access/rar/rar.h index 232009c..889309f 100644 --- a/modules/access/rar/rar.h +++ b/modules/access/rar/rar.h @@ -40,7 +40,7 @@ typedef struct { int RarProbe(stream_t *); void RarFileDelete(rar_file_t *); -int RarParse(stream_t *, int *, rar_file_t ***); +int RarParse(stream_t *, int *, rar_file_t ***, bool); int RarAccessOpen(vlc_object_t *); void RarAccessClose(vlc_object_t *); diff --git a/modules/access/rar/stream.c b/modules/access/rar/stream.c index cd81764..68b4017 100644 --- a/modules/access/rar/stream.c +++ b/modules/access/rar/stream.c @@ -72,7 +72,9 @@ int RarStreamOpen(vlc_object_t *object) int count; rar_file_t **files; const int64_t position = stream_Tell(s->p_source); - if (RarParse(s->p_source, &count, &files)) { + if (RarParse(s->p_source, &count, &files, false) && + RarParse(s->p_source, &count, &files, true ) ) + { stream_Seek(s->p_source, position); msg_Err(s, "Invalid or unsupported RAR archive"); free(files); _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits