After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 725134 - hlsdemux: null pointer deref if media playlist contains no media
hlsdemux: null pointer deref if media playlist contains no media
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other All
: Normal normal
: 1.3.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-02-25 11:40 UTC by A Ashley
Modified: 2014-03-01 15:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch to fix bug725134 (1.79 KB, patch)
2014-02-25 11:52 UTC, A Ashley
none Details | Review
second version of patch (1.91 KB, patch)
2014-03-01 10:55 UTC, A Ashley
committed Details | Review

Description A Ashley 2014-02-25 11:40:44 UTC
hlsdemux causes a null pointer dereference if it fails to download the media playlist. The gst_hls_demux_update_playlist function assumes that demux->client->current->files is valid and tries to access the last item of the files list when caching the first three fragments at start up.

This bug can be reproduced by creating a master m3u8 file that contains one media playlist that does not exist.

For example:

#EXTM3U
#EXT-X-VERSION:4
#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=617508, CODECS="avc1.42001f mp4a.40.2", RESOLUTION=540x352
/404.m3u8
Comment 1 A Ashley 2014-02-25 11:52:54 UTC
Created attachment 270257 [details] [review]
Proposed patch to fix bug725134
Comment 2 Sebastian Dröge (slomo) 2014-02-25 11:58:04 UTC
I think it should just fail when it fails to fetch the playlist, and not even go to any of the code that currently does the NULL pointer dereference.
Comment 3 A Ashley 2014-02-26 08:49:49 UTC
A very good point.

This issue came to light when trying to resolve bug725137. Having done some more digging, the problem is not that the playlist fails to load, but that the playlist does not contain media assets.

bug725137 is causing the wrong URL to be generated, and the CDN provider is returning the master playlist when presented with this wrong URL.

I think this bug still stands however, as it is possible that an incorrectly configured HLS server might provide a playlist without media assets. This shouldn't cause a segfault.

I will update the bug description.
Comment 4 A Ashley 2014-02-26 08:51:26 UTC
This bug can be reproduced by creating an m3u8 file called bug725140.m3u8 that contains:

#EXTM3U
#EXT-X-VERSION:4
#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=617508, CODECS="avc1.42001f
mp4a.40.2", RESOLUTION=540x352
bug725140.m3u8
Comment 5 Sebastian Dröge (slomo) 2014-02-26 08:55:56 UTC
True, nonetheless I think additionally a change is necessary to let hlsdemux error out immediately if such problems are found that can't be recovered from.
Comment 6 Sebastian Dröge (slomo) 2014-02-27 20:49:36 UTC
Do you want to update your patch for that? Otherwise I'll do it on top of your patch
Comment 7 Sebastian Dröge (slomo) 2014-02-28 08:45:52 UTC
Shouldn't gst_m3u8_client_update() return FALSE if that happens, and then we go out of gst_hls_demux_update_playlist() directly?

The duration change is nonetheless necessary.
Comment 8 A Ashley 2014-03-01 10:55:55 UTC
Created attachment 270622 [details] [review]
second version of patch

Sorry for the delay in answering the comments - it's never a good day when it takes three OS re-installs to be able to test a three line patch!

As suggested, this version returns an error if the media playlist does not contain any media segments.
Comment 9 Sebastian Dröge (slomo) 2014-03-01 15:35:33 UTC
Thanks for updating the patch :)

commit b7ef52c515d9de53a08c450eef84492ba79796b3
Author: Alex Ashley <bugzilla@ashley-family.net>
Date:   Tue Feb 25 11:45:46 2014 +0000

    hlsdemux: Segfaults if playlist has no media files
    
    hlsdemux causes a null pointer dereference if the media playlist
    does not contain any media files. The gst_m3u8_client_get_duration
    function assumes that demux->client->current->files is valid when
    computing duration.
    
    gst_m3u8_client_update needed to be modified to check for the
    case of downloading an M3U8 file that doesn't contain any media
    files, and returning an error to gsthlsdemux.c
    
    This bug can be reproduced by creating a master m3u8 file that
    contains one media playlist that points back to the master m3u8
    file.  For example create a file called bug725134.m3u8:
      #EXTM3U
      #EXT-X-VERSION:4
      #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=1251135, CODECS="avc1.42001f mp4a.40.2", RESOLUTIO
      bug725134.m3u8
    
    https://bugzilla.gnome.org/show_bug.cgi?id=725134