Don't read/write from/to the XDG dirs if the home directory is disabled

This commit is contained in:
Akira TAGOH 2014-06-30 12:37:36 +09:00
parent 274f2181f2
commit 5004e8e01f
2 changed files with 37 additions and 4 deletions

View File

@ -2014,8 +2014,12 @@ FcConfigXdgCacheHome (void)
else
{
const FcChar8 *home = FcConfigHome ();
size_t len = home ? strlen ((const char *)home) : 0;
size_t len;
if (!home)
return NULL;
len = strlen ((const char *)home);
ret = malloc (len + 7 + 1);
if (ret)
{
@ -2039,8 +2043,12 @@ FcConfigXdgConfigHome (void)
else
{
const FcChar8 *home = FcConfigHome ();
size_t len = home ? strlen ((const char *)home) : 0;
size_t len;
if (!home)
return NULL;
len = strlen ((const char *)home);
ret = malloc (len + 8 + 1);
if (ret)
{
@ -2064,8 +2072,12 @@ FcConfigXdgDataHome (void)
else
{
const FcChar8 *home = FcConfigHome ();
size_t len = home ? strlen ((const char *)home) : 0;
size_t len;
if (!home)
return NULL;
len = strlen ((const char *)home);
ret = malloc (len + 13 + 1);
if (ret)
{

View File

@ -2051,7 +2051,14 @@ FcParseDir (FcConfigParse *parse)
attr = FcConfigGetAttribute (parse, "prefix");
if (attr && FcStrCmp (attr, (const FcChar8 *)"xdg") == 0)
{
prefix = FcConfigXdgDataHome ();
/* home directory might be disabled.
* simply ignore this element.
*/
if (!prefix)
goto bail;
}
data = FcStrBufDoneStatic (&parse->pstack->str);
if (!data)
{
@ -2142,11 +2149,18 @@ static void
FcParseCacheDir (FcConfigParse *parse)
{
const FcChar8 *attr;
FcChar8 *prefix = NULL, *p, *data;
FcChar8 *prefix = NULL, *p, *data = NULL;
attr = FcConfigGetAttribute (parse, "prefix");
if (attr && FcStrCmp (attr, (const FcChar8 *)"xdg") == 0)
{
prefix = FcConfigXdgCacheHome ();
/* home directory might be disabled.
* simply ignore this element.
*/
if (!prefix)
goto bail;
}
data = FcStrBufDone (&parse->pstack->str);
if (!data)
{
@ -2254,7 +2268,14 @@ FcParseInclude (FcConfigParse *parse)
deprecated = FcTrue;
attr = FcConfigGetAttribute (parse, "prefix");
if (attr && FcStrCmp (attr, (const FcChar8 *)"xdg") == 0)
{
prefix = FcConfigXdgConfigHome ();
/* home directory might be disabled.
* simply ignore this element.
*/
if (!prefix)
goto bail;
}
if (prefix)
{
size_t plen = strlen ((const char *)prefix);