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 762148 - dashdemux: correctly handle an HTTP-XSDATE that is exactly the size of the date string
dashdemux: correctly handle an HTTP-XSDATE that is exactly the size of the da...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal blocker
: 1.6.4
Assigned To: GStreamer Maintainers
GStreamer Maintainers
1.6.4
Depends on:
Blocks:
 
 
Reported: 2016-02-16 14:55 UTC by Florin Apostol
Modified: 2016-04-14 17:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (1.98 KB, patch)
2016-02-16 14:55 UTC, Florin Apostol
none Details | Review
proposed patch (1.87 KB, patch)
2016-02-23 10:53 UTC, Florin Apostol
committed Details | Review

Description Florin Apostol 2016-02-16 14:55:05 UTC
The code in the gst_dash_demux_parse_http_xsdate() was trying to
handle the case where the string is not null terminated by resizing
the buffer and appending a zero byte. This does not work if the buffer
is exactly the length of the string because the gst_buffer_resize()
function does not re-allocate the buffer, it just changes its size.

If a buffer is passed to gst_dash_demux_parse_http_xsdate() that is
exactly the length of the string, the function fails with an assert
failure in gst_buffer_resize().
Comment 1 Florin Apostol 2016-02-16 14:55:49 UTC
Created attachment 321396 [details] [review]
proposed patch
Comment 2 Tim-Philipp Müller 2016-02-19 08:56:58 UTC
Comment on attachment 321396 [details] [review]
proposed patch

Thanks, looks good, just a few small comments:

>+  gpointer str;

gchar *str;
 
>+  str = g_malloc0 (gst_buffer_get_size (buffer) + 1);
>+  if (gst_buffer_map (buffer, &mapinfo, GST_MAP_READ)) {
>+    memcpy (str, mapinfo.data, gst_buffer_get_size (buffer));

Could just do

  str = g_strndup (mapinfo.data, mapinfo.size);

here which will add a 0-terminator for you.
Comment 3 Sebastian Dröge (slomo) 2016-02-23 09:35:13 UTC
Comment on attachment 321396 [details] [review]
proposed patch

Florin, can you update the patch?
Comment 4 Florin Apostol 2016-02-23 10:53:04 UTC
Created attachment 321935 [details] [review]
proposed patch
Comment 5 Sebastian Dröge (slomo) 2016-02-23 12:43:43 UTC
commit 72e46a447818a484e24caeecd33915612e4b0be8
Author: Florin Apostol <florin.apostol@oregan.net>
Date:   Tue Feb 23 10:49:40 2016 +0000

    dashdemux: correctly handle an HTTP-XSDATE that is exactly the size of the date string
    
    The code in the gst_dash_demux_parse_http_xsdate() was trying to
    handle the case where the string is not null terminated by resizing
    the buffer and appending a zero byte. This does not work if the buffer
    is exactly the length of the string because the gst_buffer_resize()
    function does not re-allocate the buffer, it just changes its size.
    
    If a buffer is passed to gst_dash_demux_parse_http_xsdate() that is
    exactly the length of the string, the function fails with an assert
    failure in gst_buffer_resize().
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762148