]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[Core] Coverity: Use of 32-bit time_t
authorAndrey Volk <andywolk@gmail.com>
Wed, 4 Oct 2023 15:24:16 +0000 (18:24 +0300)
committerGitHub <noreply@github.com>
Wed, 4 Oct 2023 15:24:16 +0000 (18:24 +0300)
* [Core] Coverity: 1500270 Use of 32-bit time_t

* [Core] Coverity: 1500229 Use of 32-bit time_t

* [Core] Coverity: 1500235 Use of 32-bit time_t

* [Core] Coverity: 1500244 Use of 32-bit time_t

* [Core] Coverity: 1500250 Use of 32-bit time_t

* [Core] Coverity: 1500245 Use of 32-bit time_t

* [Core] Coverity: 1500255 Use of 32-bit time_t

* [Core] Coverity: 1500370 Use of 32-bit time_t

* Cleanup

src/switch_core_media.c
src/switch_ivr_originate.c
src/switch_rtp.c
src/switch_utils.c

index ca6c05e0a9aae36f43ec4d9d7c17e32116ee04fe..4b6d8aff8b6a75f38d6ec588cb77ab65b8bc0a38 100644 (file)
@@ -2066,13 +2066,13 @@ SWITCH_DECLARE(switch_status_t) switch_media_handle_create(switch_media_handle_t
                switch_mutex_init(&session->media_handle->control_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
 
                session->media_handle->engines[SWITCH_MEDIA_TYPE_AUDIO].ssrc =
-                       (uint32_t) ((intptr_t) &session->media_handle->engines[SWITCH_MEDIA_TYPE_AUDIO] + (uint32_t) time(NULL));
+                       (uint32_t) ((intptr_t) &session->media_handle->engines[SWITCH_MEDIA_TYPE_AUDIO] + (switch_time_t) time(NULL));
 
                session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO].ssrc =
-                       (uint32_t) ((intptr_t) &session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO] + (uint32_t) time(NULL) / 2);
+                       (uint32_t) ((intptr_t) &session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO] + (switch_time_t) time(NULL) / 2);
 
                session->media_handle->engines[SWITCH_MEDIA_TYPE_TEXT].ssrc =
-                       (uint32_t) ((intptr_t) &session->media_handle->engines[SWITCH_MEDIA_TYPE_TEXT] + (uint32_t) time(NULL) / 2);
+                       (uint32_t) ((intptr_t) &session->media_handle->engines[SWITCH_MEDIA_TYPE_TEXT] + (switch_time_t) time(NULL) / 2);
 
 
 
@@ -10526,7 +10526,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
        }
 
        if (!smh->owner_id) {
-               smh->owner_id = (uint32_t) switch_epoch_time_now(NULL) - port;
+               smh->owner_id = (uint32_t)(switch_time_t)switch_epoch_time_now(NULL) - port;
        }
 
        if (!smh->session_id) {
@@ -11836,7 +11836,7 @@ SWITCH_DECLARE(void) switch_core_media_set_udptl_image_sdp(switch_core_session_t
        }
 
        if (!smh->owner_id) {
-               smh->owner_id = (uint32_t) switch_epoch_time_now(NULL) - port;
+               smh->owner_id = (uint32_t)(switch_time_t)switch_epoch_time_now(NULL) - port;
        }
 
        if (!smh->session_id) {
@@ -12050,7 +12050,7 @@ SWITCH_DECLARE(void) switch_core_media_patch_sdp(switch_core_session_t *session)
                                family = strchr(smh->mparams->sipip, ':') ? "IP6" : "IP4";
 
                                if (!smh->owner_id) {
-                                       smh->owner_id = (uint32_t) switch_epoch_time_now(NULL) * 31821U + 13849U;
+                                       smh->owner_id = (uint32_t)(switch_time_t) switch_epoch_time_now(NULL) * 31821U + 13849U;
                                }
 
                                if (!smh->session_id) {
index 0b06d6029cd96f541a3cffdea5f507dfbe3cda51..3c1771682b44454bd9916a5779d650e9ee1ecff2 100644 (file)
@@ -320,8 +320,10 @@ static int check_per_channel_timeouts(originate_global_t *oglobals,
                                delayed_min = oglobals->originate_status[i].per_channel_delay_start;
                        }
                }
-               early_exit_time = delayed_min - (uint32_t) elapsed;
+
+               early_exit_time = delayed_min - (uint32_t)(switch_time_t) elapsed;
        }
+
        for (i = 0; i < max; i++) {
                if (oglobals->originate_status[i].peer_channel && oglobals->originate_status[i].per_channel_delay_start &&
                        (elapsed > oglobals->originate_status[i].per_channel_delay_start || active_channels == 0)) {
@@ -334,6 +336,7 @@ static int check_per_channel_timeouts(originate_global_t *oglobals,
                                                oglobals->originate_status[i].per_channel_timelimit_sec = 1;
                                        }
                                }
+
                                if (oglobals->originate_status[i].per_channel_progress_timelimit_sec) {
                                        if (oglobals->originate_status[i].per_channel_progress_timelimit_sec > early_exit_time) {
                                                /* IN theory this check is not needed ( should just be if !0 then -= with no else), if its not 0 it should always be greater.... */
@@ -342,6 +345,7 @@ static int check_per_channel_timeouts(originate_global_t *oglobals,
                                                oglobals->originate_status[i].per_channel_progress_timelimit_sec = 1;
                                        }
                                }
+
                                oglobals->originate_status[i].per_channel_delay_start -= delayed_min;
                        } else {
                                oglobals->originate_status[i].per_channel_delay_start = 0;
index 17c93f2fa28069f241f4ecd2bcfd53816fa2486e..506085d86d5e6f870374779a343a220a98c349d6 100644 (file)
@@ -4324,8 +4324,9 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
        if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) {
                switch_sockaddr_create(&rtp_session->rtcp_from_addr, pool);
        }
+
        rtp_session->seq = (uint16_t) rand();
-       rtp_session->ssrc = (uint32_t) ((intptr_t) rtp_session + (uint32_t) switch_epoch_time_now(NULL));
+       rtp_session->ssrc = (uint32_t) ((intptr_t) rtp_session + (switch_time_t) switch_epoch_time_now(NULL));
 #ifdef DEBUG_TS_ROLLOVER
        rtp_session->last_write_ts = TS_ROLLOVER_START;
 #endif
@@ -8061,7 +8062,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
                /* If the marker was set, and the timestamp seems to have started over - set a new SSRC, to indicate this is a new stream */
                if (m && !switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND) && (rtp_session->rtp_bugs & RTP_BUG_CHANGE_SSRC_ON_MARKER) &&
                        (rtp_session->flags[SWITCH_RTP_FLAG_RESET] || (rtp_session->ts <= rtp_session->last_write_ts && rtp_session->last_write_ts > 0))) {
-                       switch_rtp_set_ssrc(rtp_session, (uint32_t) ((intptr_t) rtp_session + (uint32_t) switch_epoch_time_now(NULL)));
+                       switch_rtp_set_ssrc(rtp_session, (uint32_t) ((intptr_t) rtp_session + (switch_time_t) switch_epoch_time_now(NULL)));
                }
 
                if (!switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO) && !switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL)) {
index c51953f0cffc34deb4d238b8989ee6569f1cb52b..df7a507920a3f2ce7becd595b4f8ba84f99732dd 100644 (file)
@@ -1161,7 +1161,7 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
                switch_safe_free(dupfile);
        }
 
-       switch_snprintf(filename, 80, "%s%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, (int) switch_epoch_time_now(NULL), rand() & 0xffff);
+       switch_snprintf(filename, 80, "%s%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, (int)(switch_time_t) switch_epoch_time_now(NULL), rand() & 0xffff);
 
        if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644)) > -1) {
                if (file) {