[LIBREPORT ABRT] added checks for locked dump directory to dd_* functions, closes #133

Petr Kubat pkubat at redhat.com
Tue Aug 20 12:44:43 UTC 2013


Signed-off-by: Petr Kubat <pkubat at redhat.com>
---
 src/lib/dump_dir.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/lib/dump_dir.c b/src/lib/dump_dir.c
index c1037b3..c3f5c57 100644
--- a/src/lib/dump_dir.c
+++ b/src/lib/dump_dir.c
@@ -811,6 +811,12 @@ static int delete_file_dir(const char *dir, bool skip_lock_file)
 
 int dd_delete(struct dump_dir *dd)
 {
+    if (!dd->locked)
+    {
+        error_msg("dump_dir is not locked for writing");
+        return -1;
+    }
+    
     int r = delete_file_dir(dd->dd_dirname, /*skip_lock_file:*/ true);
     dd->locked = 0; /* delete_file_dir already removed .lock */
     dd_close(dd);
@@ -1214,6 +1220,12 @@ report_result_t *find_in_reported_to(struct dump_dir *dd, const char *prefix)
 
 int dd_rename(struct dump_dir *dd, const char *new_path)
 {
+    if (!dd->locked)
+    {
+        error_msg("dump_dir is not locked for writing");
+        return -1;
+    }
+    
     int res = rename(dd->dd_dirname, new_path);
     if (res == 0)
     {
@@ -1221,6 +1233,7 @@ int dd_rename(struct dump_dir *dd, const char *new_path)
         dd->dd_dirname = rm_trailing_slashes(new_path);
     }
     return res;
+
 }
 
 /* Utility function */
-- 
1.8.3.1



More information about the Crash-catcher mailing list