fix pt_cache_tmp_name bug
authorTero Marttila <terom@fixme.fi>
Mon, 25 Jan 2010 04:00:04 +0200
changeset 76 2e07f7dccb67
parent 75 5d69e51ebd55
child 77 29c57814204a
fix pt_cache_tmp_name bug
src/lib/cache.c
--- a/src/lib/cache.c	Mon Jan 25 03:01:22 2010 +0200
+++ b/src/lib/cache.c	Mon Jan 25 04:00:04 2010 +0200
@@ -198,10 +198,10 @@
     }
 }
 
-static int pt_cache_tmp_name (struct pt_cache *cache, char tmp_path[1024])
+static int pt_cache_tmp_name (struct pt_cache *cache, char tmp_path[], size_t tmp_len)
 {
     // get .tmp path
-    if (path_with_fext(cache->path, tmp_path, sizeof(tmp_path), ".tmp"))
+    if (path_with_fext(cache->path, tmp_path, tmp_len, ".tmp"))
         RETURN_ERROR(PT_ERR_PATH);
 
     return 0;
@@ -227,7 +227,7 @@
     int err;
 
     // get .tmp path
-    if ((err = pt_cache_tmp_name(cache, tmp_path)))
+    if ((err = pt_cache_tmp_name(cache, tmp_path, sizeof(tmp_path))))
         return err;
 
     // open for write, create, fail if someone else already opened it for update
@@ -376,7 +376,7 @@
     int err;
     
     // get .tmp path
-    if ((err = pt_cache_tmp_name(cache, tmp_path)))
+    if ((err = pt_cache_tmp_name(cache, tmp_path, sizeof(tmp_path))))
         return err;
 
     // rename
@@ -399,7 +399,7 @@
     pt_cache_abort(cache);
 
     // get .tmp path
-    if ((err = pt_cache_tmp_name(cache, tmp_path))) {
+    if ((err = pt_cache_tmp_name(cache, tmp_path, sizeof(tmp_path)))) {
         log_warn_errno("pt_cache_tmp_name: %s: %s", cache->path, pt_strerror(err));
         
         return;