summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-02-09 22:35:44 +0100
committerLennart Poettering <lennart@poettering.net>2011-02-09 22:35:51 +0100
commit4329d03bca8936fe3b3f697f4e9108b591b7a7fe (patch)
tree25d65f32e7b0bc8b2bf78d45920dd425b3470fe2
parent786b4b05dc1bfc725995f4c2556d49aec5e2ae1b (diff)
cache: don't use $HOME when it is not set
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=610754
-rw-r--r--src/cache.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/cache.c b/src/cache.c
index 2a8f957..17b5e83 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -176,6 +176,11 @@ static int db_open(void) {
if ((ret = get_cache_home(&c)) < 0)
goto finish;
+ if (!c) {
+ ret = CA_ERROR_NOTFOUND;
+ goto finish;
+ }
+
/* Try to create, just in case it doesn't exist yet. We don't do
* this recursively however. */
mkdir(c, 0755);
@@ -396,21 +401,23 @@ static int get_last_change(time_t *t) {
if ((ret = ca_get_data_home(&e)) < 0)
goto finish;
- if (!(k = ca_new(char, strlen(e) + sizeof("/sounds")))) {
- ca_free(e);
- ret = CA_ERROR_OOM;
- goto finish;
- }
+ *t = 0;
- sprintf(k, "%s/sounds", e);
- ca_free(e);
+ if (e) {
+ if (!(k = ca_new(char, strlen(e) + sizeof("/sounds")))) {
+ ca_free(e);
+ ret = CA_ERROR_OOM;
+ goto finish;
+ }
- if (stat(k, &st) >= 0)
- *t = st.st_mtime;
- else
- *t = 0;
+ sprintf(k, "%s/sounds", e);
+ ca_free(e);
+
+ if (stat(k, &st) >= 0)
+ *t = st.st_mtime;
- ca_free(k);
+ ca_free(k);
+ }
g = ca_get_data_dirs();