]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
main/rtp_engine: Format NTP timestamps as unsigned ints
authorMatthew Jordan <mjordan@digium.com>
Sat, 6 Sep 2014 22:20:27 +0000 (22:20 +0000)
committerMatthew Jordan <mjordan@digium.com>
Sat, 6 Sep 2014 22:20:27 +0000 (22:20 +0000)
On some systems, a timeval's tv_sec/tv_usec will be unsigned lont ints, as
opposed to long ints. When the RTP engine formats these as strings, it was
previously formatting them as signed integers, which can result in some
odd negative timestamp values (particularly on 32-bit systems). This patch
formats the values as unsigned long integers.

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

main/rtp_engine.c

index 7a73f985ad733b63299038cbe91f9d06a9e05cfc..5fcf077544a70d92d6f57d1ca2abebaaec9c35aa 100644 (file)
@@ -1876,8 +1876,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,