Commit Graph

15 Commits

Author SHA1 Message Date
Pau Espin c8241421bc rtp: Avoid memcpy(len=0)
Change-Id: I7618c6509b67465d21271ea632bccc8cf11e4852
2022-08-11 20:31:18 +02:00
Pau Espin 841fe23f9f rtp: Delay rtph ptr assign after validating length
Make coverity happy, since this seems to spread as a tainted error
further below.

Related: Coverity CID#273000
Change-Id: I5d457183043d4c902f473b828815b9c62a01d47d
2022-06-29 18:11:21 +02:00
Harald Welte bea215a565 Add SPDX-License-Identifier + Copyright statements
Change-Id: I43bb1c4a889421907a1a08eb29c96f2330ab00ec
2017-11-13 01:21:03 +09:00
Pablo Neira Ayuso 5994198208 src: _snprintf() helper functions nul-terminate buffers, if possible
This patch inconditionally initializes the buffer we get to
nul-terminate it, whenever possible. It's a very simple solution to
catch three overly corner cases:

1) snprintf() returns -1, very much unlikely in practise.

2) msg->len == 0: In such case, I would expect this function is never
   called with an empty message, but let's be safe in this case too.

3) If your buffer is empty, it doesn't nul-terminate the buffer.

Change-Id: I97e517f2d98e83894ea707c63489559302ff6bd2
2017-09-12 13:28:41 +02:00
Pablo Neira Ayuso 14af167a55 osmux: fix buffer management mess in snprintf() calls
SNPRINTF_BUFFER_SIZE() looks too complex, previous version maintains two
different variables to account for the remaining space in the buffer,
one of them is always decremented based on what snprintf() returns,
which may result in underflow. These variables are swapped - not used
consistently - all over this code.

Replace this macro by a simplified version, with one single parameter to
account for remaining space. This macro also deals with two corner
cases:

1) snprintf() fails, actually never happens in practise, but
   documentation indicates it may return -1, so let's catch this case
   from here to stick to specs.

2) There is not enough space in the buffer, in that case, keep
   increasing offset, so we know how much would have been printed, just
   like snprintf() does.

Thanks to Pau Espin for reporting, and Holger for clues on this.
I have run osmux_test and, at quick glance, it looks good.

Change-Id: I5b5d6ec57a02f57c23b1ae86dbd894bad28ea797
2017-09-11 18:06:37 +00:00
Pablo Neira Ayuso 9c5f01e7b2 rtp: return offset in osmo_rtp_snprintf()
Instead of the result of the last snprintf() call.

Change-Id: I10066d73387be96a4e1f3349d700405beb138076
2017-09-05 14:57:52 +02:00
Pau Espin 728c2df796 rtp.c: Fix print format
Fixes compilation warning

Change-Id: I0146a19bf852c9e27d265a098dc9d7a337424e10
2017-07-13 21:32:26 +02:00
Holger Hans Peter Freyther 86115434f1 endian: Use the new endian macros for portability
Use the new macros to deal with little/big endian. Im a bit
worried to make this change due the little test coverage in
this module but in case of a typo the elements would not be
defined.
2015-03-22 09:38:36 +01:00
Pablo Neira Ayuso 92b9a4c6a2 rtp: fix wrong time arithmetics in osmo_rtp_build
rtp.c:154:26: warning: The left operand to '/' is always 0
        frame_diff = (usec_diff / 20000);
                      ~~~~~~~~~ ^
rtp.c:157:43: warning: The left operand to '-' is always 0
                long int frame_diff_excess = frame_diff - 1;
                                             ~~~~~~~~~~ ^
rtp.c:153:39: warning: The right operand to '+' is always 0
        usec_diff = tv_diff.tv_sec * 1000000 + tv_diff.tv_usec;
                                             ^ ~~~~~~~~~~~~~~~
rtp.c:153:29: warning: The left operand to '*' is always 0
        usec_diff = tv_diff.tv_sec * 1000000 + tv_diff.tv_usec;
                    ~~~~~~~~~~~~~~ ^
4 warnings generated.

Reported by Holger Hans Peter Freyther.
2013-05-22 12:21:29 +02:00
Pablo Neira Ayuso 33817320cb rtp: add osmo_rtp_snprintf
To print the RTP header and payload.
2012-08-06 21:04:21 +02:00
Pablo Neira Ayuso efaae10304 rtp: add new parameter to osmo_rtp_get_payload to obtain payload length 2012-07-12 13:01:28 +02:00
Pablo Neira Ayuso e142ddfd77 rtp: split osmo_rtp_parse in two functions
This patch splits osmo_rtp_parse in two functions:

osmo_rtp_get_hdr
osmo_rtp_get_payload

So we can validate corrent RTP header to access its fields. Then,
obtain the payload.
2012-07-07 17:40:17 +02:00
Pablo Neira Ayuso f52b3c8b11 rtp: remove unused rtp_handle parameter from osmo_rtp_parse
And also adjust example files to use the new function.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2012-07-03 20:03:01 +02:00
Pablo Neira Ayuso f04b5f66f3 rtp: move RTP header definitions to include rtp.h
Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2012-07-03 18:44:32 +02:00
Pablo Neira Ayuso 72cd95b352 add RTP support
This patch adds the initial RTP support for libosmo-netif, it's based
on Harald's RTP support available in openBSC.

I have also added a couple of example to show how our new channel
infrastructure interacts with the RTP layer.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2012-02-23 13:44:26 +01:00