int retval = 0;
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char *timebuf = ctime(&alarm_context.c_due_time);
- timebuf[strlen(timebuf) - 1] = '\0'; // to avoid new line
- sprintf(log_message, "wakeup time: %d, %s", (int)alarm_context.c_due_time, timebuf);
+ if (timebuf)
+ timebuf[strlen(timebuf) - 1] = '\0'; // to avoid new line
+ snprintf(log_message, sizeof(log_message), "wakeup time: %d, %s", (int)alarm_context.c_due_time, timebuf);
#endif
ALARM_MGR_LOG_PRINT("alarm_context.c_due_time is %d.", (int)alarm_context.c_due_time);
ALARM_MGR_EXCEPTION_PRINT("Alarm IRQs is not supported.");
}
ALARM_MGR_EXCEPTION_PRINT("RTC_WKALM_SET disabled ioctl is failed. errno = %s", strerror(errno));
-
- close(gfd);
- gfd = 0;
return;
}
ALARM_MGR_EXCEPTION_PRINT("[alarm-server]RTC_WKALM_SET disabled ioctl is successfully done.");
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
__save_module_log("FAIL: SET RTC", log_message);
#endif
-
- close(gfd);
- gfd = 0;
return;
}
ALARM_MGR_EXCEPTION_PRINT("[alarm-server]RTC ALARM_SET ioctl is successfully done.");
"less than 10 sec. RTC alarm does not need to be set");
}
#endif /* __WAKEUP_USING_RTC__ */
-
- close(gfd);
- gfd = 0;
return;
}
}
char *timebuf = ctime(&_time);
- timebuf[strlen(timebuf) - 1] = '\0'; // to avoid new line
- sprintf(log_message, "RTC & OS =%d, %s", (int)_time, timebuf);
+ if (timebuf)
+ timebuf[strlen(timebuf) - 1] = '\0'; // to avoid new line
+ snprintf(log_message, sizeof(log_message), "RTC & OS =%d, %s", (int)_time, timebuf);
__save_module_log(log_tag, log_message);
#endif
- close(gfd);
- gfd = 0;
-
return 1;
}
ALARM_MGR_EXCEPTION_PRINT("alarm_id[%d] is expired.", alarm_id);
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- sprintf(log_message, "alarmID: %d, pid: %d, duetime: %d", alarm_id, app_pid, (int)__alarm_info->due_time);
+ snprintf(log_message, sizeof(log_message), "alarmID: %d, pid: %d, duetime: %d", alarm_id, app_pid, (int)__alarm_info->due_time);
__save_module_log("EXPIRED", log_message);
- memset(log_message, '\0', sizeof(log_message));
#endif
if (__alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE) {
return false;
}
else {
- if (read(fd, process_name, 512) <= 0)
+ if (read(fd, process_name, sizeof(process_name) - 1) <= 0)
{
ALARM_MGR_EXCEPTION_PRINT("Unable to get the process name.");
close(fd);
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char *timebuf = ctime(&new_time);
- timebuf[strlen(timebuf) - 1] = '\0'; // to avoid newline
- sprintf(log_message, "Current: %d, New: %d, %s, diff: %f", cur_time, new_time, timebuf, diff_time);
+ if (timebuf)
+ timebuf[strlen(timebuf) - 1] = '\0'; // to avoid newline
+ snprintf(log_message, sizeof(log_message), "Current: %d, New: %d, %s, diff: %f", cur_time, new_time, timebuf, diff_time);
__save_module_log("CHANGE TIME", log_message);
#endif
current_time = time(NULL);
alarm_tm = localtime(¤t_time);
+ if (alarm_tm == NULL) {
+ ALARM_MGR_EXCEPTION_PRINT("alarm_tm is NULL");
+ return true;
+ }
+
alarm_tm->tm_year = year;
alarm_tm->tm_mon = mon;
}
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- sprintf(log_message, "wakeup rtc time: %d, %s", (int)rtc_time, ctime(&rtc_time));
+ snprintf(log_message, sizeof(log_message), "wakeup rtc time: %d, %s", (int)rtc_time, ctime(&rtc_time));
__save_module_log(log_tag, log_message);
#endif
- close(gfd);
- gfd = 0;
g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
return true;
}
} else {
strncpy(log_tag, "FAIL: SET TIMEZONE", strlen("FAIL: SET TIMEZONE"));
}
- sprintf(log_message, "Set the timezone to %s.", tzpath_str);
+ snprintf(log_message, sizeof(log_message), "Set the timezone to %s.", tzpath_str);
__save_module_log(log_tag, log_message);
#endif
g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", alarm_id, return_code));
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- sprintf(log_message, "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
+ snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
alarm_id, uid, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
__save_module_log(log_tag, log_message);
#endif
g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", alarm_id, return_code));
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- sprintf(log_message, "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
+ snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
alarm_id, uid, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
__save_module_log(log_tag, log_message);
#endif
int is_ref, int method, gpointer user_data)
{
alarm_info_t alarm_info;
- int retval = 0;
int return_code = ALARMMGR_RESULT_SUCCESS;
int alarm_id = 0;
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
uid = __get_caller_uid(name);
pid = __get_caller_pid(name);
- if (retval != ALARMMGR_RESULT_SUCCESS) {
- return_code = retval;
- g_dbus_method_invocation_return_value(invoc,
- g_variant_new("(ii)", alarm_id, return_code));
-#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- /* TODO: fix the log message */
- if (is_ref)
- sprintf(log_message,
- "uid: %d, pid: %d, Smack denied (alarm-server::alarm-ref-periodic, w)", uid, pid);
- else
- sprintf(log_message,
- "uid: %d, pid: %d, Smack denied (alarm-server::alarm-periodic, w)", uid, pid);
-
- __save_module_log("FAIL: CREATE", log_message);
-#endif
- return true;
- }
-
alarm_info.start.year = 1900;
alarm_info.start.month = 1;
alarm_info.start.day = 0;
g_dbus_method_invocation_return_value(invoc,
g_variant_new("(ii)", alarm_id, return_code));
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- sprintf(log_message, "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
+ snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
alarm_id, uid, pid, alarm_info.start.year, alarm_info.start.month,
alarm_info.start.day, alarm_info.start.hour,
alarm_info.start.min, alarm_info.start.sec);
g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- sprintf(log_message, "alarmID: %d, uid: %d, pid: %d", alarm_id, uid, pid);
+ snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d", alarm_id, uid, pid);
__save_module_log(log_tag, log_message);
#endif
return_code = ERR_ALARM_SYSTEM_FAIL;
g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- sprintf(log_message, "pid: %d. Can not get the unique_name.", pid);
+ snprintf(log_message, sizeof(log_message), "pid: %d. Can not get the unique_name.", pid);
__save_module_log("FAIL: DELETE ALL", log_message);
#endif
return true;
}
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- sprintf(log_message, "uid: %d, pid: %d, unique_name: %s", uid, pid, app_name);
+ snprintf(log_message, sizeof(log_message), "uid: %d, pid: %d, unique_name: %s", uid, pid, app_name);
__save_module_log("DELETE ALL", log_message);
#endif
g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- sprintf(log_message, "alarmID: %d, appname: %s, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
+ snprintf(log_message, sizeof(log_message), "alarmID: %d, appname: %s, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
alarm_id, app_service_name, uid, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
__save_module_log(log_tag, log_message);
#endif
// Open a DB
time(¤t_time);
localtime_r(¤t_time, ¤t_tm);
- sprintf(db_path_tmp, "/tmp/alarmmgr_%d%d%d_%02d%02d%02d.db",
+ snprintf(db_path_tmp, sizeof(db_path_tmp), "/tmp/alarmmgr_%d%d%d_%02d%02d%02d.db",
current_tm.tm_year + 1900, current_tm.tm_mon + 1, current_tm.tm_mday, current_tm.tm_hour, current_tm.tm_min, current_tm.tm_sec);
db_path = strdup(db_path_tmp);