Fix Coverity defects 02/154502/2 accepted/tizen/unified/20171013.193024 submit/tizen/20171012.130939
authorSeungbae Shin <seungbae.shin@samsung.com>
Tue, 10 Oct 2017 10:14:13 +0000 (19:14 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 12 Oct 2017 00:51:58 +0000 (09:51 +0900)
[Version] 0.11.26
[Issue Type] Security

Change-Id: I83114daea560103ce66ee03fc0f86399c891fcc1

common/mm_sound_dbus.c
mm_sound_client.c
packaging/libmm-sound.spec
server/mm_sound_mgr_codec.c
server/plugin/tone/mm_sound_plugin_codec_tone.c
server/plugin/wav/mm_sound_plugin_codec_wave.c

index 5ddc30f..1b432d5 100644 (file)
@@ -194,7 +194,7 @@ static const GDBusErrorEntry mm_sound_error_entries[] =
 
 static int _parse_error_msg(char *full_err_msg, char **err_name, char **err_msg)
 {
-       char *save_p, *domain, *_err_name, *_err_msg;
+       char *save_p = NULL, *domain, *_err_name, *_err_msg;
 
        if (!(domain = strtok_r(full_err_msg, ":", &save_p))) {
                debug_error("get domain failed");
index 4ba6246..2dcbbc5 100644 (file)
@@ -960,6 +960,9 @@ int __convert_volume_type_to_str(int volume_type, char **volume_type_str)
        case VOLUME_TYPE_VOICE:
                *volume_type_str = "voice";
                break;
+       default:
+               debug_error("unexpected volume type [%d]", volume_type);
+               return MM_ERROR_SOUND_INTERNAL;
        }
        if (!strncmp(*volume_type_str,"", VOLUME_TYPE_LEN)) {
                debug_error("could not find the volume_type[%d] in this switch case statement", volume_type);
index 22d6334..ab337a7 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.11.25
+Version:    0.11.26
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index 4739960..24dfa19 100644 (file)
@@ -484,7 +484,7 @@ cleanup:
                                debug_error("focus cleaning up failed[0x%x]", err);
                                return MM_ERROR_POLICY_INTERNAL;
                        }
-               } else if (~(param->session_options & MM_SESSION_OPTION_PAUSE_OTHERS)) {
+               } else if (!(param->session_options & MM_SESSION_OPTION_PAUSE_OTHERS)) {
                        err = mm_sound_unset_focus_watch_callback(param->focus_wcb_id);
                        if (err) {
                                debug_error("focus watch cleaning up failed[0x%x]", err);
@@ -746,7 +746,7 @@ cleanup:
                                debug_error("focus cleaning up failed[0x%x]", err);
                                return MM_ERROR_POLICY_INTERNAL;
                        }
-               } else if (~(param->session_options & MM_SESSION_OPTION_PAUSE_OTHERS)) {
+               } else if (!(param->session_options & MM_SESSION_OPTION_PAUSE_OTHERS)) {
                        err = mm_sound_unset_focus_watch_callback(param->focus_wcb_id);
                        if (err) {
                                debug_error("focus watch cleaning up failed[0x%x]", err);
@@ -911,7 +911,7 @@ int MMSoundMgrCodecClearFocus(int pid)
                                                        err = MM_ERROR_POLICY_INTERNAL;
                                                        goto cleanup;
                                                }
-                                       } else if (~(g_slots[slotid].session_options & MM_SESSION_OPTION_PAUSE_OTHERS)) {
+                                       } else if (!(g_slots[slotid].session_options & MM_SESSION_OPTION_PAUSE_OTHERS)) {
                                                err = mm_sound_unset_focus_watch_callback(g_slots[slotid].focus_wcb_id);
                                                if (err) {
                                                        debug_error("mm_sound_unset_focus_watch_callback failed [0x%x]", err);
@@ -979,7 +979,7 @@ static int _MMSoundMgrCodecStopCallback(int param)
                                        err = MM_ERROR_POLICY_INTERNAL;
                                        goto finish;
                                }
-                       } else if (~(g_slots[param].session_options & MM_SESSION_OPTION_PAUSE_OTHERS)) {
+                       } else if (!(g_slots[param].session_options & MM_SESSION_OPTION_PAUSE_OTHERS)) {
                                err = mm_sound_unset_focus_watch_callback(g_slots[param].focus_wcb_id);
                                if (err) {
                                        debug_error("mm_sound_unset_focus_watch_callback failed [0x%x]", err);
index 66ce076..78c47c2 100644 (file)
@@ -935,6 +935,12 @@ _create_tone(double *sample, TONE _TONE, double volume, int *toneSize, gboolean
                        quota++;
                }
 
+               if (quota == 0) {
+                       debug_error("quota is zero!!!");
+                       g_free(buffer);
+                       return NULL;
+               }
+
                for (i = 0; i < sample_size; i++) {
                        /*
                         * We add the fundamental frequencies together.
index 32a1a75..19cc427 100644 (file)
@@ -206,6 +206,11 @@ static void _pa_stream_write_callback(pa_stream *s, size_t length, void *userdat
        frame_size = pa_frame_size(&h->spec);
        data_length = length;
 
+       if (frame_size == 0) {
+               debug_error("frame size can't be 0");
+               return;
+       }
+
        if (pa_stream_begin_write(s, &data, &data_length) < 0) {
                debug_error("failed to pa_stream_begin_write()");
                return;