Commit graph

109 commits

Author SHA1 Message Date
Jakub Adam
50c32a8963 rtpbuffer: make sure header extension buffer is initialized
Based upon valgrind finding:

Conditional jump or move depends on uninitialised value(s)
   at 0x4AFF589: read_rtp_header_extensions (gstrtpbasedepayload.c:1197)
   by 0x4AFF9E5: gst_rtp_base_depayload_set_headers
(gstrtpbasedepayload.c:1298)
   by 0x4AFFEE0: gst_rtp_base_depayload_do_push
(gstrtpbasedepayload.c:1413)
   by 0x4AFFF53: gst_rtp_base_depayload_push
(gstrtpbasedepayload.c:1448)
   by 0x4AFDEBA: gst_rtp_base_depayload_handle_buffer
(gstrtpbasedepayload.c:801)
   by 0x4AFE41E: gst_rtp_base_depayload_chain_list
(gstrtpbasedepayload.c:899)
   by 0x48F262C: gst_pad_chain_data_unchecked (gstpad.c:4414)
   by 0x48F3333: gst_pad_push_data (gstpad.c:4655)
   by 0x48F3DF8: gst_pad_push_list (gstpad.c:4814)
   by 0x4AFAD87: gst_rtp_base_payload_push_list
(gstrtpbasepayload.c:1978)
   by 0x72B3154: gst_rtp_vp8_pay_handle_buffer (gstrtpvp8pay.c:672)
   by 0x4AF7031: gst_rtp_base_payload_chain (gstrtpbasepayload.c:868)
 Uninitialised value was created by a heap allocation
   at 0x483C77F: malloc (in
/usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x4B8BA78: g_malloc (gmem.c:106)
   by 0x4BA3A9D: g_slice_alloc (gslice.c:1069)
   by 0x488D777: _sysmem_new_block (gstallocator.c:413)
   by 0x488DB28: default_alloc (gstallocator.c:512)
   by 0x488D3E8: gst_allocator_alloc (gstallocator.c:310)
   by 0x4AE97E3: gst_rtp_buffer_set_extension_data (gstrtpbuffer.c:856)
   by 0x4AF9EC6: set_headers (gstrtpbasepayload.c:1757)
   by 0x489FE4D: gst_buffer_list_foreach (gstbufferlist.c:287)
   by 0x4AFA87A: gst_rtp_base_payload_prepare_push
(gstrtpbasepayload.c:1915)
   by 0x4AFAD06: gst_rtp_base_payload_push_list
(gstrtpbasepayload.c:1970)
   by 0x72B3154: gst_rtp_vp8_pay_handle_buffer (gstrtpvp8pay.c:672)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1075>
2021-04-03 09:39:02 +00:00
Will Miller
ac72a6adaa gstrtpbuffer: fix header extension length validation
We validate the header extensions length of an RTP buffer by comparing
it against the block size. Since we multiply the length in words by 4 to
get the length in bytes, a suitably large length could cause a wrapround
of the uint16, giving a lower length which erroneously passes the check
and allows the buffer to be mapped.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/864>
2020-10-12 15:01:22 +01:00
Miguel Paris
f265e5cbd5 rtpbuffer: add_extension_onebyte_header: fix the proper wordlen
The wordlen ("length") MUST represent the total "number of 32-bit words
in the extension, excluding the four-octet extension header" (rfc3550).
There are cases where already existent padding is reused for adding
the new extension. So the new wordlen should be updated if the new
added extension makes it to increase.
2020-03-19 14:18:20 +01:00
Miguel Paris
2d4d28d662 rtpbuffer: get_onebyte_header_end_offset: allow 0 offset
There are some cases where the full extension data could be padding.
In order to make the GstRtpBuffer robust enough, this change supports
this case.
2020-03-19 14:18:20 +01:00
Havard Graff
19e4d1a93c rtpbuffer: add gst_rtp_buffer_get_extension_onebyte_header_from_bytes
So that one can parse the GBytes returned by gst_rtp_buffer_get_extension_bytes
2020-02-04 08:44:43 +00:00
Thibault Saunier
909baa2360 Pass the code through codespell 2019-08-30 13:05:36 +00:00
Tim-Philipp Müller
ca15315565 gst-libs: include config.h in all source files
This will be needed later when we get our export define from config.h
2018-08-13 09:23:34 +01:00
Mark Nauwelaerts
fe6f65b1c2 rtp: fix some GIR annotations
Mostly related to out and array parameters.
2018-04-23 19:33:12 +02:00
Miguel Paris
bae3636197 rtp: fix gst_rtp_buffer_ext_timestamp taking into account backwards
If timestamp goes forwards more than allowed, we consider that the
timestamp belongs to the previous counting, so the extended timestamp
is unwrapped.

https://bugzilla.gnome.org/show_bug.cgi?id=783443
2017-12-21 17:27:42 -05:00
Sebastian Dröge
d33c407f6b rtp: Require gconstpointer instead of gpointer for gst_rt[c]p_buffer_new_copy_data() 2017-11-17 14:14:55 +02:00
Thibault Saunier
099ac9faf2 docs: Convert gtkdoc comments to markdown
Modernizing the documentation, making it simpler to read an
modify and allowing us to possibly switch to hotdoc in the
future.
2017-03-10 18:19:17 -03:00
Miguel Paris
036bdf5d2d rtpbuffer: Fix ensure_buffers() if whole packet is in one GstMemory
When gst_rtp_buffer_add_extension_onebyte_header() is used over a
GstRtpBuffer that only contains a memory for the whole packet,
ensure_buffers function crashes at the next point:

mem = gst_memory_copy (rtp->map[i].memory, offset, rtp->size[i]);

when i==2 because the payload is not mapped.

In addition the offset is calculated subtracting in the wrong direction.

https://bugzilla.gnome.org/show_bug.cgi?id=774959
2016-11-25 13:15:24 +02:00
Sebastian Dröge
69f90adbaf rtpbuffer: Add some const qualifiers
gst_rtp_buffer_add_extension_onebyte_header() and
gst_rtp_buffer_add_extension_twobytes_header() can have a const argument for
the actual extension data.
2016-07-26 17:46:38 +03:00
Stian Selnes
0a668c1866 rtpbuffer: Add map flag to skip padding
Encrypted RTP buffers may contain encrypted padding, hence it's
necessary to have an option to relax the validation in order to
successfully map the buffer.

When the flag GST_RTP_BUFFER_MAP_FLAG_SKIP_PADDING is set
gst_rtp_buffer_map() will map the buffer like if padding is not
present.

https://bugzilla.gnome.org/show_bug.cgi?id=752705
2015-10-15 22:42:37 +03:00
Sebastian Dröge
79d4765525 Revert "rtpbuffer: increase logging level when map fails"
This reverts commit e3c8a82017.

It causes too much noise in the logs.
2015-10-15 22:40:50 +03:00
Miguel París Díaz
e3c8a82017 rtpbuffer: increase logging level when map fails
https://bugzilla.gnome.org/show_bug.cgi?id=756641
2015-10-15 16:48:08 +03:00
Brian Peters
1273848bf5 rtpbuffer: avoid accessing NULL buffer even more
Previous commit was incompletely applied.

https://bugzilla.gnome.org/show_bug.cgi?id=753001
2015-07-30 15:16:57 +01:00
Brian Peters
04c69952c0 rtp: buffer: don't access NULL buffer pointer
unmap will set rtpbuffer->buffer to NULL, so we need to
save the pointer to access it while the RTP buffer is
unmapped.

https://bugzilla.gnome.org/show_bug.cgi?id=753001
2015-07-30 14:30:44 +01:00
Tim-Philipp Müller
6410aba1aa rtpbuffer: optimise payload mapping for buffers with one memory
Micro-optimisation: if the buffer consist of just one memory, we
know we have already mapped that memory to read the headers, so
no need to map it another time to get to the payload data, we
can just set up the payload data details right there and then
and avoid another map call in gst_rtp_buffer_get_payload().
Adds up when receiving RTP-payloaded raw video which can easily
be thousands of packets per frame.
2015-06-01 19:01:23 +01:00
Sebastian Dröge
8f13a31bae rtpbuffer: Link to an explanation why the seqnum comparison function does the right thing even for wraparounds 2015-03-09 11:12:46 +01:00
Luis de Bethencourt
7ca8e6e71d rtp: Do not use deprecated gtk-doc 'Rename to' tag
GObject introspection GTK-Doc tag "Rename to" has been deprecated, changing to
rename-to annotation.

https://bugzilla.gnome.org/show_bug.cgi?id=739514
2014-11-02 15:14:13 +00:00
Vincent Penquerc'h
20344f6dc9 rtpbuffer: add a const where appropriate 2014-10-30 11:42:02 +00:00
Vincent Penquerc'h
db8460cbd8 rtpbuffer: avoid underflow in size calculation 2014-05-02 15:10:07 +01:00
Stian Selnes
0011d8cbb5 rtpbuffer: fix memory leak when gst_rtp_buffer_map fails
Make sure rtp->data[3] is set before jumping to error path.

https://bugzilla.gnome.org/show_bug.cgi?id=729117
2014-04-29 08:46:29 +02:00
Tim-Philipp Müller
bcb8068e27 docs: remove outdated and pointless 'Last reviewed' lines from docs
They are very confusing for people, and more often than not
also just not very accurate. Seeing 'last reviewed: 2005' in
your docs is not very confidence-inspiring. Let's just remove
those comments.
2014-04-26 23:28:57 +01:00
Sebastian Rasmussen
c734f9fba8 rtpbuffer: Allow subbuffering of empty buffers
See https://bugzilla.gnome.org/show_bug.cgi?id=720162
2013-12-10 12:38:56 +01:00
Sebastian Dröge
76985c5e81 rtpbuffer: Fix gst_rtp_buffer_ext_timestamp() with clang 5 on iOS/ARM
The bitwise NOT operator is not defined on signed integers.
Thanks to Wim Taymans for finding the cause.

https://bugzilla.gnome.org/show_bug.cgi?id=711819
2013-11-13 20:15:02 +01:00
Wim Taymans
240c7234f6 rtpbuffer: check for valid payload type
The payload type can't be between 72 and 76 because with the marker bit set,
this could be mistaken for an RTCP packet then. We do a relaxed check and
only refuse 72-76 when the marker bit is set. The effect is that when
we try to map an RTCP packet as an RTP packet, we will certainly fail.
2013-09-13 16:05:58 +02:00
Branko Subasic
4dd5c5b808 rtpbuffer: add gst_rtp_buffer_get_payload_bytes
The function gst_rtp_buffer_get_payload can not be used in Python
because it lacks necessary length parameter. This patch adds a new
function, gst_rtp_buffer_get_payload_bytes, to use from Python
bindings. The new function has the advisory "Rename to:" annotation
so it can replace the gst_rtp_buffer_get_payload whan creating
bindings.

The function gst_rtp_buffer_get_extension_bytes is also added. It wraps
gst_rtp_buffer_get_extension_data which doesn't work in Python due to
incomplete annotation and because it returns the length as number of
32-bit words.

https://bugzilla.gnome.org/show_bug.cgi?id=698562
2013-06-18 11:23:40 +02:00
Thijs Vermeir
2887485358 rtp: fix compiler warning
comparison is always true due to limited range of data type
2012-12-18 15:27:48 +01:00
Wim Taymans
af3f75f3a9 rtpbuffer: protect against empty buffers 2012-11-12 11:18:16 +01:00
Tim-Philipp Müller
5f59b4f7ee Fix FSF address
https://bugzilla.gnome.org/show_bug.cgi?id=687520
2012-11-03 23:05:09 +00:00
Tim-Philipp Müller
392d3225ce rtp: fix buffer leak when gst_rtp_buffer_map() fails because of broken data
Makes libs/rtp unit test valgrind clean.
2012-08-22 09:20:55 +01:00
Wim Taymans
1968127650 rtp: Fix extension data support
Allocate header, payload and padding in separate memory blocks in
gst_rtp_buffer_allocate().
don't use part of the payload data as storage for the extension data but store
it in a separate memory block that can be enlarged when needed.
Rework the one and two-byte header extension to make it reserve space for the
extra extension first.
Fix RTP unit test. Don't map the complete buffer or make assumptions on the
memory layout of the underlaying implementation. We can now always add extension
data because we have a separate memory block for it.
2012-08-22 09:56:39 +02:00
Wim Taymans
2d6fd0f72d rtp: fix extension length calculation 2012-08-22 09:56:39 +02:00
Wim Taymans
f548e58385 rtp: remove unused field 2012-08-22 09:56:39 +02:00
Andoni Morales Alastruey
d2aebc7f94 rtpbuffer: use proper format for gsize 2012-08-08 17:41:19 +02:00
Wim Taymans
11a494d5c9 rtp: Add support for multiple memory blocks in RTP
Add support RTP buffers with multiple memory blocks. We allow one block for the
header, one for the extension data, N for data and one memory block for the
padding.
Remove the validate function, we validate now when we map because we need to
parse things in order to map multiple memory blocks.
2012-07-17 16:41:36 +02:00
Evan Nemerson
f21c4667b9 rtp: add many missing annotations on RTP/RTCP buffer functions 2012-07-17 11:10:37 +02:00
Edward Hervey
2817bdadc9 libs: Remove "Since" markers and minor doc fixups 2012-07-13 12:11:06 +02:00
Wim Taymans
296e1bf3dd rtpbuffer: removed old memory
Ensure writability of rtp buffer and remove old memory first
Fix some docs
2012-04-04 09:34:00 +02:00
Wim Taymans
92f46c07fe rtpbuffer: keep more state
Prepare for the future, make it possible to map multiple buffer regions, like
the header and the payload.
2012-04-02 10:31:18 +02:00
Wim Taymans
9ef519d99a Improve buffer allocation of wrapped memory 2012-04-01 18:11:23 +02:00
Wim Taymans
345dc31f20 update for buffer api change 2012-03-30 18:15:30 +02:00
Wim Taymans
df5253b22c update for memory api changes 2012-03-15 13:32:08 +01:00
Wim Taymans
28034226c6 update for memory api changes 2012-03-14 21:35:45 +01:00
Wim Taymans
63f3f27164 update for new memory api 2012-02-22 02:05:24 +01:00
Wim Taymans
e7575bc525 rtp: improve structures
Remove flags that is in the mapinfo now
2012-01-25 12:30:53 +01:00
Wim Taymans
fcdc385aa1 port to new map API 2012-01-25 12:30:53 +01:00
Wim Taymans
5872bcc33a Update for memory API changes 2012-01-19 12:15:18 +01:00