summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2009-10-30 23:47:27 +0100
committerKarel Klic <kklic@redhat.com>2009-10-30 23:47:27 +0100
commitd0962176b885a32b1c5aecd5ac3c0d23447c3d09 (patch)
treea876da5cefe940264b97d35e80b9cd3a7ef7e64a /src
parent0843e750bce39df0e69e4962b3c7f98294d0739b (diff)
parent276a9017d63445dd322f9a93ff34e67cbdf97dc9 (diff)
downloadabrt-d0962176b885a32b1c5aecd5ac3c0d23447c3d09.tar.gz
abrt-d0962176b885a32b1c5aecd5ac3c0d23447c3d09.tar.xz
abrt-d0962176b885a32b1c5aecd5ac3c0d23447c3d09.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src')
-rw-r--r--src/Daemon/Daemon.cpp1
-rw-r--r--src/Daemon/MiddleWare.cpp4
-rwxr-xr-xsrc/Daemon/abrt-debuginfo-install9
-rw-r--r--src/Hooks/CCpp.cpp31
4 files changed, 29 insertions, 16 deletions
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index 9615ce8..b509b9f 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -654,6 +654,7 @@ static void sanitize_dump_dir_rights()
{
ensure_root_writable_dir(DEBUG_DUMPS_DIR);
ensure_root_writable_dir(DEBUG_DUMPS_DIR"-di"); /* debuginfo cache */
+ ensure_root_writable_dir(VAR_RUN"/abrt"); /* temp dir */
}
int main(int argc, char** argv)
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index 7c5bb41..2fd4f25 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -84,12 +84,14 @@ static void DebugDumpToCrashReport(const std::string& pDebugDumpDir, map_crash_r
!dd.Exist(FILENAME_RELEASE) ||
!dd.Exist(FILENAME_EXECUTABLE))
{
- throw CABRTException(EXCEP_ERROR, "DebugDumpToCrashReport(): One or more of important file(s)'re missing.");
+ throw CABRTException(EXCEP_ERROR, "DebugDumpToCrashReport(): One or more of important file(s)'re missing");
}
+
pCrashReport.clear();
dd.InitGetNextFile();
while (dd.GetNextFile(fileName, content, isTextFile))
{
+VERB3 log(" file:'%s' text:%d", fileName.c_str(), isTextFile);
if (!isTextFile)
{
add_crash_data_to_crash_report(pCrashReport,
diff --git a/src/Daemon/abrt-debuginfo-install b/src/Daemon/abrt-debuginfo-install
index 1f947cd..ba9f9a1 100755
--- a/src/Daemon/abrt-debuginfo-install
+++ b/src/Daemon/abrt-debuginfo-install
@@ -13,9 +13,10 @@
# If CACHEDIR is specified, debuginfos should be installed there.
# If not, debuginfos should be installed into TEMPDIR.
#
-# Currently, we are called with CACHEDIR set to "/", but in the future
-# it may be omitted or set to something else. script must be ready
-# for those cases too.
+# Currently, we are called with CACHEDIR set to "/var/cache/abrt-di",
+# but in the future it may be omitted or set to something else.
+# Script must be ready for those cases too. Consider, for example,
+# corner cases of "" and "/".
#
# Output goes to GUI as debuginfo install log. The script should be careful
# to give useful, but not overly cluttered info to stdout.
@@ -70,7 +71,7 @@ test x"$cachedir" = x"" || test -d "$cachedir" || exit 2
# tempdir must not exist
test -e "$tempdir" && exit 2
-mkdir "$tempdir" || exit 2
+mkdir -- "$tempdir" || exit 2
cd "$tempdir" || exit 2
$debug && echo "Installing rpms to $tempdir"
diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp
index e6768a6..1c152e6 100644
--- a/src/Hooks/CCpp.cpp
+++ b/src/Hooks/CCpp.cpp
@@ -54,32 +54,41 @@ static char* get_cmdline(pid_t pid)
char path[PATH_MAX];
char cmdline[COMMAND_LINE_SIZE];
snprintf(path, sizeof(path), "/proc/%u/cmdline", (int)pid);
- int dst = 0;
+ int idx = 0;
int fd = open(path, O_RDONLY);
if (fd >= 0)
{
int len = read(fd, cmdline, sizeof(cmdline) - 1);
- if (len >= 0)
+ close(fd);
+
+ if (len > 0)
{
- int src = 0;
- while (src < len)
+ /* In Linux, there is always one trailing NUL byte,
+ * prevent it from being replaced by space below.
+ */
+ if (cmdline[len - 1] == '\0')
+ len--;
+
+ while (idx < len)
{
- char ch = cmdline[src++];
+ unsigned char ch = cmdline[idx];
if (ch == '\0')
{
- cmdline[dst++] = ' ';
+ cmdline[idx++] = ' ';
}
- /* TODO: maybe just ch >= ' '? */
- else if (isspace(ch) || (isascii(ch) && !iscntrl(ch)))
+ else if (ch >= ' ' && ch <= 0x7e)
{
- cmdline[dst++] = ch;
+ cmdline[idx++] = ch;
+ }
+ else
+ {
+ cmdline[idx++] = '?';
}
}
}
- close(fd);
}
- cmdline[dst] = '\0';
+ cmdline[idx] = '\0';
return xstrdup(cmdline);
}