#include <stdio.h>
#include <stdlib.h>
+#include <sys/stat.h>
#include "include/mm_sound_mgr_focus.h"
#include "../include/mm_sound_common.h"
return ret;
}
+static int __check_file_safety(const char *file)
+{
+ struct stat ls;
+
+ if ((lstat(file, &ls) == -1) && (errno != ENOENT)) {
+ char str_error[256];
+ strerror_r(errno, str_error, sizeof(str_error));
+ debug_error("failed to lstat() (%s, err:%s)", file, str_error);
+ return -1;
+ }
+
+ if (S_ISLNK(ls.st_mode)){
+ debug_error("symbolic link is detected (%s)", file);
+ return -1;
+ }
+
+ return 0;
+}
+
static void _invoke_watch_callback(focus_node_t *node, const char *stream_type, focus_type_e focus_type, focus_command_e command, const _mm_sound_mgr_focus_param_t *param)
{
int ret = -1;
*
**************************************/
filename = __get_focus_pipe_path(cb_data.pid, cb_data.handle, NULL, true);
- if (filename == NULL) {
+ if (filename == NULL || __check_file_safety(filename)) {
debug_error("[CB] failed to get watch pipe");
goto RELEASE;
}
+
if ((fd_FOCUS = open(filename, O_WRONLY|O_NONBLOCK)) == -1) {
char str_error[256];
strerror_r(errno, str_error, sizeof(str_error));
*
******************************************/
filename2 = __get_focus_pipe_path(cb_data.pid, cb_data.handle, "r", true);
- if (filename2 == NULL) {
+ if (filename2 == NULL || __check_file_safety(filename2)) {
debug_error("[RETCB] failed to get watch return pipe");
goto RELEASE;
}
*
**************************************/
filename = __get_focus_pipe_path(cb_data.pid, cb_data.handle, NULL, false);
- if (filename == NULL) {
+ if (filename == NULL || __check_file_safety(filename)) {
debug_error("[CB] failed to get pipe");
res = -1;
goto RELEASE;
*
******************************************/
filename2 = __get_focus_pipe_path(cb_data.pid, cb_data.handle, "r", false);
- if (filename2 == NULL) {
+ if (filename2 == NULL || __check_file_safety(filename2)) {
debug_error("[RETCB] failed to get return pipe");
res = -1;
goto RELEASE;