Skip to content
Snippets Groups Projects
Commit 11874bc5 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

demux: restore stream offset before probing (fixes #18502)

There are (roughly) three ways that a demux probe function can fail:
- file type does not match,
- file type matches but corruption is detected early,
- unexpected I/O error.

In the first case, the demuxer will typically not move the "virtual"
file offset - mostly using vlc_stream_Peek(). But in the later two
cases, the demuxer will typically have moved the file offset forward.

There are no generic ways to fix it. Seeking back might fail (leading
to ingored result warning). So we try to fix it in generic way before
trying the next demuxer. If it fails, such as due to unrecoverable I/O
error, we just skip it completely.
parent da721e6f
No related branches found
No related tags found
No related merge requests found
......@@ -175,6 +175,22 @@ static void demux_DestroyDemuxFilter(demux_t *demux)
demux_Delete(demux->p_next);
}
static int demux_Probe(void *func, va_list ap)
{
int (*probe)(vlc_object_t *) = func;
demux_t *demux = va_arg(ap, demux_t *);
/* Restore input stream offset (in case previous probed demux failed to
* to do so). */
if (vlc_stream_Tell(demux->s) != 0 && vlc_stream_Seek(demux->s, 0))
{
msg_Err(demux, "seek failure before probing");
return VLC_EGENERIC;
}
return probe(VLC_OBJECT(demux));
}
/*****************************************************************************
* demux_NewAdvanced:
* if s is NULL then load a access_demux
......@@ -245,9 +261,8 @@ demux_t *demux_NewAdvanced( vlc_object_t *p_obj, input_thread_t *p_parent_input,
if( psz_module == NULL )
psz_module = p_demux->psz_demux;
p_demux->p_module =
module_need( p_demux, "demux", psz_module,
!strcmp( psz_module, p_demux->psz_demux ) );
p_demux->p_module = vlc_module_load(p_demux, "demux", psz_module,
!strcmp(psz_module, p_demux->psz_demux), demux_Probe, p_demux);
}
else
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment