mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-04 22:47:44 -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
|
||||
int plat_get_root_dir(char *dst, int len)
|
||||
{
|
||||
#if defined(__GP2X__) || defined(PANDORA)
|
||||
return plat_get_data_dir(dst, len);
|
||||
#else
|
||||
char *home = getenv("HOME");
|
||||
size_t nb = strlen(home);
|
||||
#if !defined(__GP2X__) && !defined(PANDORA)
|
||||
const char *home = getenv("HOME");
|
||||
int ret;
|
||||
|
||||
memcpy(dst, home, nb);
|
||||
memcpy(dst + nb, PICO_HOME_DIR, sizeof PICO_HOME_DIR);
|
||||
mkdir(dst, 0755);
|
||||
return nb + sizeof(PICO_HOME_DIR) - 1;
|
||||
if (home != NULL) {
|
||||
ret = snprintf(dst, len, "%s%s", home, PICO_HOME_DIR);
|
||||
if (ret >= len)
|
||||
ret = len - 1;
|
||||
mkdir(dst, 0755);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
return plat_get_data_dir(dst, len);
|
||||
}
|
||||
|
||||
#ifdef __GP2X__
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue