notaz.gp2x.de
/
libpicofe.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
62e581e
)
handle no home and buf overflow
author
notaz
<notasas@gmail.com>
Wed, 9 Oct 2013 23:41:45 +0000
(
02:41
+0300)
committer
notaz
<notasas@gmail.com>
Wed, 9 Oct 2013 23:44:10 +0000
(
02:44
+0300)
linux/plat.c
patch
|
blob
|
blame
|
history
diff --git
a/linux/plat.c
b/linux/plat.c
index
ec381fa
..
660a095
100644
(file)
--- a/
linux/plat.c
+++ b/
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)
{
#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
#endif
+ return plat_get_data_dir(dst, len);
}
#ifdef __GP2X__
}
#ifdef __GP2X__