char *_media_svc_get_path(uid_t uid)
{
+ int len = 0;
char *result_passwd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
media_svc_error("getgrnam(users) returns NULL !");
return NULL;
}
- result_passwd = g_strdup(MEDIA_ROOT_PATH_INTERNAL);
+ len = strlen(MEDIA_ROOT_PATH_INTERNAL);
+ if (len > 0)
+ result_passwd = strndup(MEDIA_ROOT_PATH_INTERNAL, len);
} else {
char passwd_str[MEDIA_SVC_PATHNAME_SIZE] = {0, };
struct passwd *userinfo = getpwuid(uid);
media_svc_error("UID [%d] does not belong to 'users' group!", uid);
return NULL;
}
- snprintf(passwd_str, sizeof(passwd_str), "%s/%s", userinfo->pw_dir, MEDIA_CONTENT_PATH);
- result_passwd = g_strdup(passwd_str);
+ len = snprintf(passwd_str, sizeof(passwd_str), "%s/%s", userinfo->pw_dir, MEDIA_CONTENT_PATH);
+ if (len > 0)
+ result_passwd = strndup(passwd_str, len);
}
return result_passwd;
char *_media_svc_get_thumb_default_path(uid_t uid)
{
+ int len = 0;
char *result_passwd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
media_svc_error("getgrnam(users) returns NULL !");
return NULL;
}
- result_passwd = g_strdup(MEDIA_SVC_THUMB_DEFAULT_PATH);
+ len = strlen(MEDIA_SVC_THUMB_DEFAULT_PATH);
+ if (len > 0)
+ result_passwd = strndup(MEDIA_SVC_THUMB_DEFAULT_PATH, len);
} else {
char passwd_str[MEDIA_SVC_PATHNAME_SIZE] = {0, };
struct passwd *userinfo = getpwuid(uid);
media_svc_error("UID [%d] does not belong to 'users' group!", uid);
return NULL;
}
- snprintf(passwd_str, sizeof(passwd_str), "%s/share/media/.thumb/thumb_default.png", userinfo->pw_dir);
- result_passwd = g_strdup(passwd_str);
+ len = snprintf(passwd_str, sizeof(passwd_str), "%s/share/media/.thumb/thumb_default.png", userinfo->pw_dir);
+ if (len > 0)
+ result_passwd = strndup(passwd_str, len);
}
return result_passwd;
static char *__media_svc_get_thumb_path(uid_t uid)
{
+ int len = 0;
char *result_passwd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
media_svc_error("getgrnam(users) returns NULL !");
return NULL;
}
- result_passwd = g_strdup(MEDIA_SVC_THUMB_PATH_PREFIX);
+ len = strlen(MEDIA_SVC_THUMB_PATH_PREFIX);
+ if (len > 0)
+ result_passwd = strndup(MEDIA_SVC_THUMB_PATH_PREFIX, len);
} else {
char passwd_str[MEDIA_SVC_PATHNAME_SIZE] = {0, };
struct passwd *userinfo = getpwuid(uid);
media_svc_error("UID [%d] does not belong to 'users' group!", uid);
return NULL;
}
- snprintf(passwd_str, sizeof(passwd_str), "%s/share/media/.thumb", userinfo->pw_dir);
- result_passwd = g_strdup(passwd_str);
+ len = snprintf(passwd_str, sizeof(passwd_str), "%s/share/media/.thumb", userinfo->pw_dir);
+ if (len > 0)
+ result_passwd = strndup(passwd_str, len);
}
return result_passwd;
char *_media_svc_get_thumb_internal_path(uid_t uid)
{
+ int len = 0;
char *result_passwd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
media_svc_error("getgrnam(users) returns NULL !");
return NULL;
}
- result_passwd = g_strdup(MEDIA_SVC_THUMB_INTERNAL_PATH);
+ len = strlen(MEDIA_SVC_THUMB_INTERNAL_PATH);
+ if (len > 0)
+ result_passwd = strndup(MEDIA_SVC_THUMB_INTERNAL_PATH, len);
} else {
char passwd_str[MEDIA_SVC_PATHNAME_SIZE] = {0, };
struct passwd *userinfo = getpwuid(uid);
media_svc_error("UID [%d] does not belong to 'users' group!", uid);
return NULL;
}
- snprintf(passwd_str, sizeof(passwd_str), "%s/share/media/.thumb/phone", userinfo->pw_dir);
- result_passwd = g_strdup(passwd_str);
+ len = snprintf(passwd_str, sizeof(passwd_str), "%s/share/media/.thumb/phone", userinfo->pw_dir);
+ if (len > 0)
+ result_passwd = strndup(passwd_str, len);
}
return result_passwd;
char *_media_svc_get_thumb_external_path(uid_t uid)
{
+ int len = 0;
char *result_passwd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
media_svc_error("getgrnam(users) returns NULL !");
return NULL;
}
- result_passwd = g_strdup(MEDIA_SVC_THUMB_EXTERNAL_PATH);
+ len = strlen(MEDIA_SVC_THUMB_EXTERNAL_PATH);
+ if (len > 0)
+ result_passwd = strndup(MEDIA_SVC_THUMB_EXTERNAL_PATH, len);
} else {
char passwd_str[MEDIA_SVC_PATHNAME_SIZE] = {0, };
struct passwd *userinfo = getpwuid(uid);
media_svc_error("UID [%d] does not belong to 'users' group!", uid);
return NULL;
}
- snprintf(passwd_str, sizeof(passwd_str), "%s/share/media/.thumb/mmc", userinfo->pw_dir);
- result_passwd = g_strdup(passwd_str);
+ len = snprintf(passwd_str, sizeof(passwd_str), "%s/share/media/.thumb/mmc", userinfo->pw_dir);
+ if (len > 0)
+ result_passwd = strndup(passwd_str, len);
}
return result_passwd;