summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2009-10-30 17:12:39 +0100
committerKarel Klic <kklic@redhat.com>2009-10-30 17:12:39 +0100
commitf92e5d5587e57c6319d3fd8bdd351918fad27721 (patch)
treebfaf35ab0493543a3280a94e8055359b5b31ea18 /src
parent995bb1352eb5a461047d0acfc5f9648270c9b446 (diff)
downloadabrt-f92e5d5587e57c6319d3fd8bdd351918fad27721.tar.gz
abrt-f92e5d5587e57c6319d3fd8bdd351918fad27721.tar.xz
abrt-f92e5d5587e57c6319d3fd8bdd351918fad27721.zip
fixes based on review by Denys
Diffstat (limited to 'src')
-rw-r--r--src/Hooks/abrt-pyhook-helper.cpp42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/Hooks/abrt-pyhook-helper.cpp b/src/Hooks/abrt-pyhook-helper.cpp
index 4ac6ada6..7ad605f3 100644
--- a/src/Hooks/abrt-pyhook-helper.cpp
+++ b/src/Hooks/abrt-pyhook-helper.cpp
@@ -92,44 +92,48 @@ int main(int argc, char** argv)
struct arguments arguments;
argp_parse (&argp, argc, argv, 0, 0, &arguments);
- char path[PATH_MAX];
- snprintf(path, sizeof(path), "%s/pyhook-%ld-%s", DEBUG_DUMPS_DIR,
- (long)time(NULL), arguments.pid);
-
- CDebugDump dd;
- dd.Create(path, geteuid());
- dd.SaveText(FILENAME_ANALYZER, "Python");
- if (arguments.executable)
- dd.SaveText(FILENAME_EXECUTABLE, arguments.executable);
- if (arguments.cmdline)
- dd.SaveText("cmdline", arguments.cmdline);
- if (arguments.uuid)
- dd.SaveText("uuid", arguments.uuid);
- if (arguments.loginuid)
- dd.SaveText("uid", arguments.loginuid);
-
// Read the backtrace from stdin.
int c;
int capacity = 1024;
char *bt = (char*)malloc(capacity);
+ if (!bt)
+ {
+ printf("Error while allocating memory for backtrace.\n");
+ return 1;
+ }
char *btptr = bt;
while ((c = getchar()) != EOF)
{
- if (c >= 0 && c <= 255)
- *btptr++ = (char)c;
+ *btptr++ = (char)c;
if (btptr - bt >= capacity - 1)
{
capacity *= 2;
bt = (char*)realloc(bt, capacity);
if (!bt)
{
- printf("Error while allocating memory for backtrace.");
+ printf("Error while allocating memory for backtrace.\n");
return 1;
}
}
}
*btptr = '\0';
+ // Create directory with the debug dump.
+ char path[PATH_MAX];
+ snprintf(path, sizeof(path), "%s/pyhook-%ld-%s", DEBUG_DUMPS_DIR,
+ (long)time(NULL), arguments.pid);
+
+ CDebugDump dd;
+ dd.Create(path, geteuid());
+ dd.SaveText(FILENAME_ANALYZER, "Python");
+ if (arguments.executable)
+ dd.SaveText(FILENAME_EXECUTABLE, arguments.executable);
+ if (arguments.cmdline)
+ dd.SaveText("cmdline", arguments.cmdline);
+ if (arguments.uuid)
+ dd.SaveText("uuid", arguments.uuid);
+ if (arguments.loginuid)
+ dd.SaveText("uid", arguments.loginuid);
dd.SaveText("backtrace", bt);
free(bt);
dd.Close();