]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
main/rtp_engine: Format NTP timestamps as unsigned longs
authorMatthew Jordan <mjordan@digium.com>
Wed, 21 Jan 2015 12:56:49 +0000 (12:56 +0000)
committerMatthew Jordan <mjordan@digium.com>
Wed, 21 Jan 2015 12:56:49 +0000 (12:56 +0000)
When the RTCP reports are created, the NTP timestamps are stored as strings,
as JSON does not have an integer type long enough to store the value. However,
on 32-bit systems, a signed long may overflow for some portion of the
timestamp.

This patch corrects the overflow by formatting the timestamps as unsigned
longs.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@430840 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/rtp_engine.c

index 920b3d3e1ff48b01fafa92ab631a589522058328..11fe985cb1a261a77b9e8c4db3710bb653c833e0 100644 (file)
@@ -1947,8 +1947,8 @@ static struct ast_json *rtcp_report_to_json(struct stasis_message *msg,
        if (payload->report->type == AST_RTP_RTCP_SR) {
                char sec[32];
                char usec[32];
-               snprintf(sec, sizeof(sec), "%ld", payload->report->sender_information.ntp_timestamp.tv_sec);
-               snprintf(usec, sizeof(usec), "%ld", payload->report->sender_information.ntp_timestamp.tv_usec);
+               snprintf(sec, sizeof(sec), "%lu", payload->report->sender_information.ntp_timestamp.tv_sec);
+               snprintf(usec, sizeof(usec), "%lu", payload->report->sender_information.ntp_timestamp.tv_usec);
                json_rtcp_sender_info = ast_json_pack("{s: s, s: s, s: i, s: i, s: i}",
                                "ntp_timestamp_sec", sec,
                                "ntp_timestamp_usec", usec,