static char* __media_get_media_DB(uid_t uid)
{
+ int len = 0;
char *result_passwd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
MSAPI_DBG_ERR("UID [%d] does not belong to 'users' group!", uid);
return NULL;
}
- snprintf(passwd_str, sizeof(passwd_str), "%s/.applications/dbspace/.media.db", userinfo->pw_dir);
- result_passwd = g_strdup(passwd_str);
+ len = snprintf(passwd_str, sizeof(passwd_str), "%s/.applications/dbspace/.media.db", userinfo->pw_dir);
+ if (len > 0)
+ result_passwd = strndup(passwd_str, len);
}
return result_passwd;
static char* __msc_get_path(uid_t uid)
{
+ int len = 0;
char *result_passwd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
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;
static char* __msc_get_path(uid_t uid)
{
+ int len = 0;
char *result_passwd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
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;
static char* __ms_get_path(uid_t uid)
{
+ int len = 0;
char *result_passwd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
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;