diff options
author | Pablo Neira Ayuso <pablo@gnumonks.org> | 2017-09-12 12:44:53 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@gnumonks.org> | 2017-09-12 13:28:41 +0200 |
commit | 59941982083f7f0d6ab11f7bbb42c297a3fb8d69 (patch) | |
tree | dfdb654b4b960bec475bdee5c8f31af2f17eb0c1 /src/rtp.c | |
parent | 14af167a5553519d8164f4a21556888535eeefeb (diff) |
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
Diffstat (limited to 'src/rtp.c')
-rw-r--r-- | src/rtp.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -200,6 +200,9 @@ int osmo_rtp_snprintf(char *buf, size_t size, struct msgb *msg) uint8_t *payload; int ret, i; + if (size) + buf[0] = '\0'; + rtph = osmo_rtp_get_hdr(msg); if (rtph == NULL) return -1; |