#define THUMB_DEFAULT_HEIGHT 240
#define THUMB_BLOCK_SIZE 512
#define THUMB_ROOT_UID "0"
+#define THUMB_COMM_SOCK_PATH "/var/run/media-server/media_ipc_thumbcomm.socket"
static __thread char **arr_path;
static __thread uid_t *arr_uid;
sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
- strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcomm.socket");
+ strncpy(serv_addr.sun_path, THUMB_COMM_SOCK_PATH, strlen(THUMB_COMM_SOCK_PATH));
/* Connecting to the thumbnail server */
if (ms_cynara_enable_credentials_passing(sock) != MS_MEDIA_ERR_NONE) {
thumb_err("ms_cynara_enable_credentials_passing failed");
+ close(sock);
return FALSE;
}
char *result_psswd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
- result_psswd = strdup(THUMB_DEFAULT_PATH);
+ if (THUMB_DEFAULT_PATH != NULL)
+ result_psswd = strndup(THUMB_DEFAULT_PATH, strlen(THUMB_DEFAULT_PATH));
grpinfo = getgrnam("users");
if (grpinfo == NULL) {
thumb_err("getgrnam(users) returns NULL !");
thumb_h = req_msg->thumb_height;
thumb_path = res_msg->dst_path;
thumb_path[0] = '\0';
- max_length = sizeof(res_msg->dst_path);
+ max_length = sizeof(res_msg->dst_path) -1;
if (!g_file_test(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
thumb_err("origin_path does not exist in file system.");
char *result_psswd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
- result_psswd = strdup(THUMB_MMC_PATH);
+ if (THUMB_MMC_PATH != NULL)
+ result_psswd = strndup(THUMB_MMC_PATH, strlen(THUMB_MMC_PATH));
grpinfo = getgrnam("users");
if (grpinfo == NULL) {
thumb_err("getgrnam(users) returns NULL !");
char *result_psswd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
- result_psswd = strdup(THUMB_PHONE_PATH);
+ if (THUMB_PHONE_PATH != NULL)
+ result_psswd = strndup(THUMB_PHONE_PATH, strlen(THUMB_PHONE_PATH));
grpinfo = getgrnam("users");
if (grpinfo == NULL) {
thumb_err("getgrnam(users) returns NULL !");
char *hash_name = NULL;
/*char *thumb_dir = NULL;*/
char file_ext[255] = { 0 };
+ char *get_path = NULL;
int ret_len = 0;
media_thumb_store_type store_type = -1;
}
if (store_type == THUMB_PHONE) {
- ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", _media_thumb_phone_get_path(uid), file_ext, hash_name);
+ get_path = _media_thumb_phone_get_path(uid);
+ if (get_path != NULL)
+ ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", get_path, file_ext, hash_name);
} else if (store_type == THUMB_MMC) {
- ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", _media_thumb_mmc_get_path(uid), file_ext, hash_name);
+ get_path = _media_thumb_mmc_get_path(uid);
+ if (get_path != NULL)
+ ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", get_path, file_ext, hash_name);
} else {
- ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", _media_thumb_phone_get_path(uid), file_ext, hash_name);
+ get_path = _media_thumb_phone_get_path(uid);
+ if (get_path != NULL)
+ ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", get_path, file_ext, hash_name);
}
+ SAFE_FREE(get_path);
+
if ((ret_len < 0) || (ret_len > (int)max_thumb_path)) {
thumb_err("invalid hash path ret_len[%d]", ret_len);
return MS_MEDIA_ERR_INTERNAL;