summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2010-01-13 14:21:26 +0100
committerKarel Klic <kklic@redhat.com>2010-01-13 14:21:26 +0100
commitd548f0263bf1d707207aabe43a7c39c8419bc9d6 (patch)
tree1fc50f9a0538e1d764f1a468abc694bb81f88426 /src
parentdf1d7cd05d8f6abba8c713e773828deee19baf22 (diff)
parentf5925030be2963ddf257e6768dcd5712b0e6df08 (diff)
downloadabrt-d548f0263bf1d707207aabe43a7c39c8419bc9d6.tar.gz
abrt-d548f0263bf1d707207aabe43a7c39c8419bc9d6.tar.xz
abrt-d548f0263bf1d707207aabe43a7c39c8419bc9d6.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src')
-rw-r--r--src/Daemon/PluginManager.cpp4
-rw-r--r--src/Hooks/Makefile.am2
-rw-r--r--src/Hooks/abrt-hook-ccpp.cpp (renamed from src/Hooks/CCpp.cpp)5
-rw-r--r--src/Hooks/abrt-hook-python.cpp53
4 files changed, 48 insertions, 16 deletions
diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp
index a6550e7..e14f852 100644
--- a/src/Daemon/PluginManager.cpp
+++ b/src/Daemon/PluginManager.cpp
@@ -235,9 +235,9 @@ void CPluginManager::UnLoadPlugin(const char *pName)
delete it_plugin->second;
m_mapPlugins.erase(it_plugin);
}
- delete it_module->second;
- m_mapLoadedModules.erase(it_module);
log("UnRegistered %s plugin %s", plugin_type_str[it_module->second->GetType()], pName);
+ m_mapLoadedModules.erase(it_module);
+ delete it_module->second;
}
}
diff --git a/src/Hooks/Makefile.am b/src/Hooks/Makefile.am
index ebabd87..2b04990 100644
--- a/src/Hooks/Makefile.am
+++ b/src/Hooks/Makefile.am
@@ -3,7 +3,7 @@ bin_PROGRAMS = dumpoops
# abrt-hook-ccpp
abrt_hook_ccpp_SOURCES = \
- CCpp.cpp \
+ abrt-hook-ccpp.cpp \
hooklib.h hooklib.cpp
abrt_hook_ccpp_CPPFLAGS = \
-I$(srcdir)/../../inc \
diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/abrt-hook-ccpp.cpp
index 21fe0be..1c91dc8 100644
--- a/src/Hooks/CCpp.cpp
+++ b/src/Hooks/abrt-hook-ccpp.cpp
@@ -1,5 +1,5 @@
/*
- CCpp.cpp - the hook for C/C++ crashing program
+ abrt-hook-ccpp.cpp - the hook for C/C++ crashing program
Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
Copyright (C) 2009 RedHat inc.
@@ -23,7 +23,6 @@
#include "DebugDump.h"
#include "ABRTException.h"
#include <syslog.h>
-#include <sys/statvfs.h>
#define FILENAME_EXECUTABLE "executable"
#define FILENAME_COREDUMP "coredump"
@@ -70,7 +69,7 @@ int main(int argc, char** argv)
const char* program_name = argv[0];
error_msg_and_die("Usage: %s: DUMPDIR PID SIGNO UID CORE_SIZE_LIMIT", program_name);
}
- openlog("abrt", 0, LOG_PID | LOG_DAEMON);
+ openlog("abrt", LOG_PID, LOG_DAEMON);
logmode = LOGMODE_SYSLOG;
errno = 0;
diff --git a/src/Hooks/abrt-hook-python.cpp b/src/Hooks/abrt-hook-python.cpp
index b921fba..c8a25e3 100644
--- a/src/Hooks/abrt-hook-python.cpp
+++ b/src/Hooks/abrt-hook-python.cpp
@@ -20,7 +20,7 @@
*/
#include <getopt.h>
-#include <unistd.h>
+#include <syslog.h>
/* We can easily get rid of abrtlib (libABRTUtils.so) usage in this file,
* but DebugDump will pull it in anyway */
#include "abrtlib.h"
@@ -38,12 +38,33 @@ static char *pid;
static char *executable;
static char *uuid;
-int main(int argc, char** argv)
+/* Note: "" will return false */
+static bool isxdigit_str(const char *str)
{
- // Error if daemon is not running.
- if (!daemon_is_ok())
- error_msg_and_die("Daemon is not running.");
+ do {
+ if ((*str < '0' || *str > '9') /* not a digit */
+ && ((*str | 0x20) < 'a' || (*str | 0x20) > 'f') /* not A-F or a-f */
+ )
+ {
+ return false;
+ }
+ str++;
+ } while (*str);
+ return true;
+}
+
+static bool printable_str(const char *str)
+{
+ do {
+ if ((unsigned char)(*str) < ' ' || *str == 0x7f)
+ return false;
+ str++;
+ } while (*str);
+ return true;
+}
+int main(int argc, char** argv)
+{
// Parse options
static const struct option longopts[] = {
// name , has_arg , flag, val
@@ -79,8 +100,18 @@ int main(int argc, char** argv)
}
if (!pid || !executable || !uuid)
goto usage;
+ if (strlen(uuid) > 128 || !isxdigit_str(uuid))
+ goto usage;
+ if (strlen(executable) > PATH_MAX || !printable_str(executable))
+ goto usage;
+ // pid string is sanitized later by xatou()
-//TODO: sanitize uuid and executable (size, valid chars etc)
+ openlog("abrt", LOG_PID, LOG_DAEMON);
+ logmode = LOGMODE_SYSLOG;
+
+ // Error if daemon is not running
+ if (!daemon_is_ok())
+ error_msg_and_die("daemon is not running, python crash dump aborted");
unsigned setting_MaxCrashReportsSize = 0;
parse_conf(NULL, &setting_MaxCrashReportsSize, NULL);
@@ -94,14 +125,15 @@ int main(int argc, char** argv)
ssize_t len = full_read(STDIN_FILENO, bt, MAX_BT_SIZE-1);
if (len < 0)
{
- perror_msg_and_die("Read error");
+ perror_msg_and_die("read error");
}
bt[len] = '\0';
if (len == MAX_BT_SIZE-1)
{
- error_msg("Backtrace size limit exceeded, trimming to " MAX_BT_SIZE_STR);
+ error_msg("backtrace size limit exceeded, trimming to " MAX_BT_SIZE_STR);
}
+ // This also checks that pid is a valid numeric string
char *cmdline = get_cmdline(xatou(pid)); /* never NULL */
// Create directory with the debug dump
@@ -109,11 +141,10 @@ int main(int argc, char** argv)
snprintf(path, sizeof(path), DEBUG_DUMPS_DIR"/pyhook-%ld-%s",
(long)time(NULL), pid);
CDebugDump dd;
-
try {
dd.Create(path, getuid());
} catch (CABRTException &e) {
- error_msg_and_die("Error while creating debug dump: %s", e.what());
+ error_msg_and_die("error while creating crash dump %s: %s", path, e.what());
}
dd.SaveText(FILENAME_ANALYZER, "Python");
@@ -128,6 +159,8 @@ int main(int argc, char** argv)
dd.SaveText("uid", uid);
dd.Close();
+ log("saved python crash dump of pid %s to %s", pid, path);
+
if (setting_MaxCrashReportsSize > 0)
{
trim_debug_dumps(setting_MaxCrashReportsSize, path);