summaryrefslogtreecommitdiffstats
path: root/src/Hooks
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-02-04 21:21:14 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-02-04 21:21:14 +0100
commitd45b0c1cfe5fdd9648d880a059b13c4fbee4c8ee (patch)
tree8ff325a68a6007e4f3abea262f1bd27d56793ce2 /src/Hooks
parentf9d98f594a2b5103f0e88bf33191ad164a77c239 (diff)
parent75c6e1fc1113984b30a4d84c1cfe6e97c70c398f (diff)
Merge branch 'master' into rhel6
Diffstat (limited to 'src/Hooks')
-rw-r--r--src/Hooks/abrt-hook-ccpp.cpp10
-rw-r--r--src/Hooks/abrt-hook-python.cpp10
2 files changed, 18 insertions, 2 deletions
diff --git a/src/Hooks/abrt-hook-ccpp.cpp b/src/Hooks/abrt-hook-ccpp.cpp
index ff06234..d3f6b25 100644
--- a/src/Hooks/abrt-hook-ccpp.cpp
+++ b/src/Hooks/abrt-hook-ccpp.cpp
@@ -195,7 +195,11 @@ int main(int argc, char** argv)
const char *signame = strsignal(signal_no);
char *reason = xasprintf("Process was terminated by signal %s (%s)", signal_str, signame ? signame : signal_str);
- snprintf(path, sizeof(path), "%s/ccpp-%ld-%lu", dddir, (long)time(NULL), (long)pid);
+ unsigned path_len = snprintf(path, sizeof(path), "%s/ccpp-%ld-%lu.new",
+ dddir, (long)time(NULL), (long)pid);
+ if (path_len >= sizeof(path))
+ exit(1);
+
CDebugDump dd;
dd.Create(path, uid);
dd.SaveText(FILENAME_ANALYZER, "CCpp");
@@ -246,6 +250,10 @@ int main(int argc, char** argv)
* Classic deadlock.
*/
dd.Close();
+ char *newpath = xstrndup(path, path_len - (sizeof(".new")-1));
+ if (rename(path, newpath) != 0)
+ strcpy(path, newpath);
+ free(newpath);
/* rhbz#539551: "abrt going crazy when crashing process is respawned" */
if (setting_MaxCrashReportsSize > 0)
diff --git a/src/Hooks/abrt-hook-python.cpp b/src/Hooks/abrt-hook-python.cpp
index 90197cc..5686c17 100644
--- a/src/Hooks/abrt-hook-python.cpp
+++ b/src/Hooks/abrt-hook-python.cpp
@@ -139,8 +139,10 @@ int main(int argc, char** argv)
// Create directory with the debug dump
char path[PATH_MAX];
- snprintf(path, sizeof(path), DEBUG_DUMPS_DIR"/pyhook-%ld-%s",
+ unsigned path_len = snprintf(path, sizeof(path), DEBUG_DUMPS_DIR"/pyhook-%ld-%s.new",
(long)time(NULL), pid);
+ if (path_len >= sizeof(path))
+ exit(1);
CDebugDump dd;
try {
dd.Create(path, getuid());
@@ -160,6 +162,12 @@ int main(int argc, char** argv)
dd.SaveText(FILENAME_UID, uid);
dd.Close();
+
+ char *newpath = xstrndup(path, path_len - (sizeof(".new")-1));
+ if (rename(path, newpath) != 0)
+ strcpy(path, newpath);
+ free(newpath);
+
log("saved python crash dump of pid %s to %s", pid, path);
if (setting_MaxCrashReportsSize > 0)