mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-07 07:38:04 -04:00
handle no home and buf overflow
This commit is contained in:
parent
62e581e179
commit
af7e50060f
1 changed files with 11 additions and 9 deletions
20
linux/plat.c
20
linux/plat.c
|
@ -78,17 +78,19 @@ int plat_get_skin_dir(char *dst, int len)
|
||||||
#endif
|
#endif
|
||||||
int plat_get_root_dir(char *dst, int len)
|
int plat_get_root_dir(char *dst, int len)
|
||||||
{
|
{
|
||||||
#if defined(__GP2X__) || defined(PANDORA)
|
#if !defined(__GP2X__) && !defined(PANDORA)
|
||||||
return plat_get_data_dir(dst, len);
|
const char *home = getenv("HOME");
|
||||||
#else
|
int ret;
|
||||||
char *home = getenv("HOME");
|
|
||||||
size_t nb = strlen(home);
|
|
||||||
|
|
||||||
memcpy(dst, home, nb);
|
if (home != NULL) {
|
||||||
memcpy(dst + nb, PICO_HOME_DIR, sizeof PICO_HOME_DIR);
|
ret = snprintf(dst, len, "%s%s", home, PICO_HOME_DIR);
|
||||||
mkdir(dst, 0755);
|
if (ret >= len)
|
||||||
return nb + sizeof(PICO_HOME_DIR) - 1;
|
ret = len - 1;
|
||||||
|
mkdir(dst, 0755);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
return plat_get_data_dir(dst, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __GP2X__
|
#ifdef __GP2X__
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue