GNOME Bugzilla – Bug 386218
[asfdemux] Division by zero when seeking live streams
Last modified: 2006-12-15 17:55:34 UTC
Symptom: trying to perform a seek over an asf file reporting play_time == 0 (live stream) causes the application to crash with a "floating point exception" Expected result: gst_element_seek should report failure to seek Details: In file gst-plugins-ugly-0.10.5/gst/asfdemux/gstasfdemux.c:274 seek_packet = demux->num_packets * seek_time / demux->play_time; but nobody checks, before of this statement, that demux->play_time is valid/not null, so the application crashes with a "floating point exception". In my case the problem arises when trying to seek a file originating from the capture of a live stream, for which the file correctly reports (line numbers are from version 0.10.4 of plugins-ugly, but relevant code is unchanged in 0.10.5): gstasfdemux.c:1698:gst_asf_demux_process_ext_stream_props: start_time = 0:00:00.000000000 gstasfdemux.c:1700:gst_asf_demux_process_ext_stream_props: end_time = 0:00:00.000000000 gstasfdemux.c:1701:gst_asf_demux_process_ext_stream_props: flags = 00000000 gstasfdemux.c:1703:gst_asf_demux_process_ext_stream_props: average time per frame = 0:00:00.000000000 gstasfdemux.c:1704:gst_asf_demux_process_ext_stream_props: stream number = 1 gstasfdemux.c:1707:gst_asf_demux_process_ext_stream_props: stream language ID idx = 1 (it) gstasfdemux.c:1708:gst_asf_demux_process_ext_stream_props: stream name count = 0 gstasfdemux.c:1723:gst_asf_demux_process_ext_stream_props: payload ext sys count = 0 gstasfdemux.c:1736:gst_asf_demux_process_ext_stream_props: bytes read: 64/64 0 The seeking function should check the "seekable" flag (least significant bit of demux->ext_stream_props.flags) or at least guard against demux->play_time == 0 (which IMHO is anyway a good idea, in order to protect the application from malformed headers), and return a "normal" failure. Riccardo Brigo
Thanks for the bug report, should be fixed now: 2006-12-15 Tim-Philipp Müller <tim at centricular dot net> * gst/asfdemux/gstasfdemux.c: (gst_asf_demux_handle_seek_event), (gst_asf_demux_process_data), (gst_asf_demux_process_file), (gst_asf_demux_handle_src_query), (gst_asf_demux_change_state): * gst/asfdemux/gstasfdemux.h: Don't crash in the seek event handling code when playtime is 0, as may be the case with live streams (#386218). Implement SEEKING query so applications can query seekability without second-guessing based on whether we have a duration or not.