From 19cf9ee2c3beea056a464e6995836befdccec18d Mon Sep 17 00:00:00 2001 From: Seungbae Shin Date: Tue, 10 Oct 2017 19:14:13 +0900 Subject: [PATCH] Fix Coverity defects [Version] 0.11.26 [Issue Type] Security Change-Id: I83114daea560103ce66ee03fc0f86399c891fcc1 --- common/mm_sound_dbus.c | 2 +- mm_sound_client.c | 3 +++ packaging/libmm-sound.spec | 2 +- server/mm_sound_mgr_codec.c | 8 ++++---- server/plugin/tone/mm_sound_plugin_codec_tone.c | 6 ++++++ server/plugin/wav/mm_sound_plugin_codec_wave.c | 5 +++++ 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/common/mm_sound_dbus.c b/common/mm_sound_dbus.c index 5ddc30f..1b432d5 100644 --- a/common/mm_sound_dbus.c +++ b/common/mm_sound_dbus.c @@ -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"); diff --git a/mm_sound_client.c b/mm_sound_client.c index 4ba6246..2dcbbc5 100644 --- a/mm_sound_client.c +++ b/mm_sound_client.c @@ -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); diff --git a/packaging/libmm-sound.spec b/packaging/libmm-sound.spec index 22d6334..ab337a7 100644 --- a/packaging/libmm-sound.spec +++ b/packaging/libmm-sound.spec @@ -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 diff --git a/server/mm_sound_mgr_codec.c b/server/mm_sound_mgr_codec.c index 4739960..24dfa19 100644 --- a/server/mm_sound_mgr_codec.c +++ b/server/mm_sound_mgr_codec.c @@ -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); diff --git a/server/plugin/tone/mm_sound_plugin_codec_tone.c b/server/plugin/tone/mm_sound_plugin_codec_tone.c index 66ce076..78c47c2 100644 --- a/server/plugin/tone/mm_sound_plugin_codec_tone.c +++ b/server/plugin/tone/mm_sound_plugin_codec_tone.c @@ -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. diff --git a/server/plugin/wav/mm_sound_plugin_codec_wave.c b/server/plugin/wav/mm_sound_plugin_codec_wave.c index 32a1a75..19cc427 100644 --- a/server/plugin/wav/mm_sound_plugin_codec_wave.c +++ b/server/plugin/wav/mm_sound_plugin_codec_wave.c @@ -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; -- 2.7.4