{
da_ret_t ret = DA_RESULT_OK;
char *actual_file_path = DA_NULL;
+ char *resolved_path = DA_NULL;
void *fd = DA_NULL;
DA_LOGV("");
if (!actual_file_path)
return DA_ERR_INVALID_ARGUMENT;
+ resolved_path = realpath(actual_file_path, NULL);
+ if (resolved_path) {
+ /* Check if actual_file_path is symbolic file or not */
+ if (strcmp(resolved_path, actual_file_path) != 0) {
+ free(resolved_path);
+ return DA_ERR_INVALID_ARGUMENT;
+ }
+ } else if (errno != ENOENT) {
+ return DA_ERR_INVALID_ARGUMENT;
+ }
+
fd = fopen(actual_file_path, "a+"); // for resume
if (fd == DA_NULL) {
DA_LOGE("File open failed");
ERR:
if (DA_RESULT_OK != ret)
file_info->file_handle = DA_NULL;
-
+ free(resolved_path);
return ret;
}