summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInkyun Kil <inkyun.kil@samsung.com>2019-10-18 02:39:42 (GMT)
committerInkyun Kil <inkyun.kil@samsung.com>2019-10-18 04:16:55 (GMT)
commit03b74c25ae91e5434ecdf6c35bf11d04332b1995 (patch)
tree26a557c86a9445ac08e7bb685e747fdc0a5b4c3f
parent500e7d2206beb26dec2615baa7df440b99999a39 (diff)
downloadalarm-manager-03b74c25ae91e5434ecdf6c35bf11d04332b1995.zip
alarm-manager-03b74c25ae91e5434ecdf6c35bf11d04332b1995.tar.gz
alarm-manager-03b74c25ae91e5434ecdf6c35bf11d04332b1995.tar.bz2
Fix static analysisrefs/changes/58/215958/2
Change-Id: I43835504bdcd932365c54ba92fe602673d4b4258 Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
-rw-r--r--lib/alarm-lib.c3
-rw-r--r--server/alarm-manager-db.c11
-rw-r--r--server/alarm-manager-dbus.c20
-rwxr-xr-xserver/alarm-manager.c42
4 files changed, 25 insertions, 51 deletions
diff --git a/lib/alarm-lib.c b/lib/alarm-lib.c
index 40cec26..ac475bd 100644
--- a/lib/alarm-lib.c
+++ b/lib/alarm-lib.c
@@ -1278,9 +1278,10 @@ static int _alarmmgr_add_alarm(int alarm_type,
return ERR_ALARM_INVALID_PARAM;
}
- if (trigger_at_time < 0)
+ if (trigger_at_time < 0) {
LOGE("trigger_at_time is invalid[%ld]", trigger_at_time);
return ERR_ALARM_INVALID_PARAM;
+ }
if (destination && strlen(destination) >= MAX_PKG_NAME_LEN) {
LOGE("[alarm-lib]: destination name is too long!\n");
diff --git a/server/alarm-manager-db.c b/server/alarm-manager-db.c
index a6fa50e..12cdea2 100644
--- a/server/alarm-manager-db.c
+++ b/server/alarm-manager-db.c
@@ -269,8 +269,9 @@ void _load_alarms_from_db()
noti_len = sqlite3_column_int(stmt, col_idx++);
noti_len = noti_len ? noti_len : strlen(null_str);
noti = (char *)calloc(1, noti_len + 1);
- strncpy(noti, (const char *)sqlite3_column_text(stmt, col_idx++),
- noti_len);
+ if (noti)
+ strncpy(noti, (const char *)sqlite3_column_text(stmt, col_idx++),
+ noti_len);
start->year = sqlite3_column_int(stmt, col_idx++);
start->month = sqlite3_column_int(stmt, col_idx++);
start->day = sqlite3_column_int(stmt, col_idx++);
@@ -298,8 +299,10 @@ void _load_alarms_from_db()
__alarm_info->dst_service_name_mod =
STRDUP_WITH_NULLCMP(dst_service_name_mod);
__alarm_info->bundle = STRDUP_WITH_NULLCMP(bundle);
- __alarm_info->noti = STRDUP_WITH_NULLCMP(noti);
- free(noti);
+ if (noti) {
+ __alarm_info->noti = STRDUP_WITH_NULLCMP(noti);
+ free(noti);
+ }
if (is_disabled) {
_alarm_set_next_duetime(__alarm_info);
diff --git a/server/alarm-manager-dbus.c b/server/alarm-manager-dbus.c
index 9c16f3d..8b50382 100644
--- a/server/alarm-manager-dbus.c
+++ b/server/alarm-manager-dbus.c
@@ -373,8 +373,15 @@ static void __alarm_send_noti_to_application_reply(
g_error_free(error);
if (is_existed) {
- entry->zombie_mode = true;
watch_info = (struct watch_info_t *)calloc(1, sizeof(struct watch_info_t));
+ if (watch_info == NULL) {
+ LOGE("Out of memory");
+ free(reply_alarm_id);
+ return;
+ }
+
+ entry->zombie_mode = true;
+
watch_info->alarm_id = entry->alarm_id;
watch_info->watch_id = g_bus_watch_name_on_connection(
alarm_context.connection,
@@ -425,6 +432,11 @@ void _alarm_send_noti_to_application_by_dbus(const char *app_service_name,
alarm_id, service_name);
} else {
reply_alarm_id = (alarm_id_t *)calloc(1, sizeof(alarm_id_t));
+ if (reply_alarm_id == NULL) {
+ LOGE("Out of memory");
+ return;
+ }
+
*reply_alarm_id = alarm_id;
g_dbus_connection_call(alarm_context.connection,
service_name,
@@ -611,9 +623,9 @@ static void handle_method_call(GDBusConnection *connection,
GVariant *parameters, GDBusMethodInvocation *invoc,
gpointer user_data)
{
- int ret;
- int num_of_alarm;
- int alarm_id;
+ int ret = ALARMMGR_RESULT_SUCCESS;
+ int num_of_alarm = 0;
+ int alarm_id = 0;
const char *name = g_dbus_method_invocation_get_sender(invoc);
uid_t uid = __get_caller_uid(name);
pid_t pid = __get_caller_pid(name);
diff --git a/server/alarm-manager.c b/server/alarm-manager.c
index 4ce7e5f..7b7c16e 100755
--- a/server/alarm-manager.c
+++ b/server/alarm-manager.c
@@ -1589,8 +1589,6 @@ static void __expire_dbus_activation(__alarm_info_t *alarm_info)
alarm_info->alarm_id, alarm_info->alarm_info.msec, alarm_info->uid); /* dbus auto activation */
LOGD("after _alarm_send_noti_to_application_by_dbus");
}
-
- return 0;
}
void _alarm_expired()
@@ -2259,8 +2257,6 @@ int alarm_manager_alarm_create_appsvc(GVariant *parameters, uid_t uid, pid_t pid
char *bundle_data;
*alarm_id = _alarm_id;
- if (uid < 0 || pid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
g_variant_get(parameters, "(iiiiiiiiiixiix&s)",
&start_year, &start_month, &start_day, &start_hour, &start_min,
@@ -2355,8 +2351,6 @@ int alarm_manager_alarm_create_noti(GVariant *parameters, uid_t uid, pid_t pid,
char *noti_data;
*alarm_id = _alarm_id;
- if (uid < 0 || pid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
g_variant_get(parameters, "(iiiiiiiiiixiix&s)",
&start_year, &start_month, &start_day, &start_hour, &start_min,
@@ -2427,8 +2421,6 @@ int alarm_manager_alarm_create(GVariant *parameters, uid_t uid, pid_t pid, int *
char *reserved_service_name_mod = NULL;
*alarm_id = _alarm_id;
- if (uid < 0 || pid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
g_variant_get(parameters, "(&s&siiiiiiiiiiiiix&s&s)",
&app_service_name, &app_service_name_mod,
@@ -2502,8 +2494,6 @@ int alarm_manager_alarm_create_periodic(GVariant *parameters, uid_t uid,
int interval, is_ref, method;
*alarm_id = _alarm_id;
- if (uid < 0 || pid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
g_variant_get(parameters, "(&s&siii)", &app_service_name,
&app_service_name_mod, &interval, &is_ref, &method);
@@ -2569,9 +2559,6 @@ int alarm_manager_alarm_delete(GVariant *parameters, uid_t uid, pid_t pid)
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
int alarm_id;
- if (uid < 0 || pid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
-
g_variant_get(parameters, "(i)", &alarm_id);
return_code = __check_modifiable(uid, pid, alarm_id);
@@ -2603,9 +2590,6 @@ int alarm_manager_alarm_delete_all(GVariant *parameters, uid_t uid, pid_t pid)
bool is_deleted = false;
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
- if (uid < 0 || pid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
-
if (__get_cached_unique_name(pid, app_name, sizeof(app_name), NULL, uid) == false) {
snprintf(log_message, sizeof(log_message), "pid: %d. Can not get the unique_name.", pid);
_save_module_log("FAIL: DELETE ALL", log_message);
@@ -2666,9 +2650,6 @@ int alarm_manager_alarm_update(GVariant *parameters, uid_t uid, pid_t pid)
time_t mode_interval, reserved_info;
gint64 tmp_mode_interval, tmp_reserved_info;
- if (uid < 0 || pid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
-
g_variant_get(parameters, "(iiiiiiiiiixiixi)",
&alarm_id, &start_year, &start_month, &start_day, &start_hour,
&start_min, &start_sec, &end_year, &end_month, &end_day,
@@ -2719,8 +2700,6 @@ int alarm_manager_alarm_get_number_of_ids(uid_t uid, pid_t pid, int *num_of_ids)
int _num_of_ids = 0;
*num_of_ids = _num_of_ids;
- if (uid < 0 || pid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
if (__get_cached_unique_name(pid, app_name, sizeof(app_name), NULL, uid) == false)
return ERR_ALARM_SYSTEM_FAIL;
@@ -2754,9 +2733,6 @@ int alarm_manager_alarm_get_list_of_ids(GVariant *parameters, uid_t uid,
*alarm_array = g_variant_new("ai", NULL);
- if (uid < 0 || pid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
-
g_variant_get(parameters, "(i)", &max_number_of_ids);
if (max_number_of_ids <= 0) {
@@ -2798,9 +2774,6 @@ int alarm_manager_alarm_get_appsvc_info(GVariant *parameters, uid_t uid, gchar *
int return_code = ALARMMGR_RESULT_SUCCESS;
int alarm_id;
- if (uid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
-
g_variant_get(parameters, "(i)", &alarm_id);
SECURE_LOGD("called for uid(%d), alarm_id(%d)\n", uid, alarm_id);
@@ -2835,9 +2808,6 @@ int alarm_manager_alarm_get_noti_info(GVariant *parameters, uid_t uid, gchar **n
int return_code = ALARMMGR_RESULT_SUCCESS;
int alarm_id;
- if (uid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
-
g_variant_get(parameters, "(i)", &alarm_id);
SECURE_LOGD("called for uid(%d), alarm_id(%d)\n", uid, alarm_id);
@@ -2871,9 +2841,6 @@ int alarm_manager_alarm_get_info(GVariant *parameters, uid_t uid, alarm_info_t *
alarm_info_t *_alarm_info = NULL;
int alarm_id;
- if (uid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
-
g_variant_get(parameters, "(i)", &alarm_id);
SECURE_LOGD("called for uid(%d), alarm_id(%d)\n", uid, alarm_id);
@@ -2916,9 +2883,6 @@ int alarm_manager_alarm_get_next_duetime(GVariant *parameters, uid_t uid, time_t
__alarm_info_t *find_item = NULL;
int alarm_id;
- if (uid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
-
g_variant_get(parameters, "(i)", &alarm_id);
SECURE_LOGD("called for alarm_id(%d)\n", alarm_id);
@@ -2944,9 +2908,6 @@ int alarm_manager_alarm_get_next_duetime(GVariant *parameters, uid_t uid, time_t
int alarm_manager_alarm_get_all_info(uid_t uid, char **db_path)
{
- if (uid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
-
return _get_db_path_for_all_info(uid, &(*db_path));
}
@@ -2961,9 +2922,6 @@ int alarm_manager_alarm_set_global(GVariant *parameters, uid_t uid)
int alarm_id;
gboolean global;
- if (uid < 0)
- return ERR_ALARM_SYSTEM_FAIL;
-
g_variant_get(parameters, "(ib)", &alarm_id, &global);
SECURE_LOGD("called for uid(%d), alarm_id(%d)\n", uid, alarm_id);