diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-11 07:22:13 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-11 07:22:13 +0100 |
| commit | 14ef0cfe72faf6696df3ef8f42927e9458ccbeeb (patch) | |
| tree | c5d3a3169fc31f212d507553beb67920be92ebcd | |
| parent | b1c4304104910c4bc066cd43f9784fe2f3ddf1ad (diff) | |
| download | abrt-14ef0cfe72faf6696df3ef8f42927e9458ccbeeb.tar.gz abrt-14ef0cfe72faf6696df3ef8f42927e9458ccbeeb.tar.xz abrt-14ef0cfe72faf6696df3ef8f42927e9458ccbeeb.zip | |
*: misc fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | lib/Plugins/CCpp.cpp | 2 | ||||
| -rw-r--r-- | lib/Plugins/FileTransfer.cpp | 20 | ||||
| -rw-r--r-- | lib/Plugins/RunApp.cpp | 4 | ||||
| -rw-r--r-- | lib/Utils/CommLayerInner.cpp | 6 | ||||
| -rw-r--r-- | lib/Utils/DebugDump.cpp | 10 | ||||
| -rw-r--r-- | lib/Utils/DebugDump.h | 2 | ||||
| -rw-r--r-- | lib/Utils/Polkit.cpp | 10 | ||||
| -rw-r--r-- | lib/Utils/xatonum.cpp | 4 | ||||
| -rw-r--r-- | src/Applet/CCApplet.cpp | 2 | ||||
| -rw-r--r-- | src/Daemon/CrashWatcher.cpp | 12 | ||||
| -rwxr-xr-x | src/Daemon/abrt-debuginfo-install | 6 | ||||
| -rw-r--r-- | src/Hooks/CCpp.cpp | 2 | ||||
| -rw-r--r-- | src/Hooks/abrt-hook-python.cpp | 2 |
13 files changed, 46 insertions, 36 deletions
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index a7f005c..46c2f28 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -627,7 +627,7 @@ static bool DebuginfoCheckPolkit(int uid) //parent int status; - if (waitpid(child_pid, &status, 0) > 0 && WEXITSTATUS(status) == 0) + if (waitpid(child_pid, &status, 0) > 0 && WIFEXITED(status) && WEXITSTATUS(status) == 0) { return true; //authorization OK } diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp index 60e1e66..9d7a59a 100644 --- a/lib/Plugins/FileTransfer.cpp +++ b/lib/Plugins/FileTransfer.cpp @@ -110,13 +110,11 @@ parameter "something" to each filename, now used in create_zip, but can be useful for some future archivers as well */ -static void traverse_directory(const char * directory, void * something, - void (*func)(void *, const char *) ) +static void traverse_directory(const char *directory, void *something, + void (*func)(void *, const char *)) { - DIR * dp; - struct dirent * dirp; - char complete_name[BUFSIZ]; - char * end; + DIR *dp; + struct dirent *dirp; dp = opendir(directory); if (dp == NULL) @@ -127,14 +125,8 @@ static void traverse_directory(const char * directory, void * something, { if (is_regular_file(dirp, directory)) { - end = stpcpy(complete_name, directory); - if (end[-1] != '/') - { - *end++ = '/'; - } - end = stpcpy(end, dirp->d_name); - - func(something, complete_name); + string complete_name = concat_path_file(directory, dirp->d_name); + func(something, complete_name.c_str()); } } closedir(dp); diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp index c1f725b..e2147e2 100644 --- a/lib/Plugins/RunApp.cpp +++ b/lib/Plugins/RunApp.cpp @@ -40,6 +40,10 @@ void CActionRunApp::Run(const char *pActionDir, const char *pArgs) vector_string_t args; parse_args(pArgs, args, '"'); + if (args.size() <= COMMAND) + { + return; + } const char *cmd = args[COMMAND].c_str(); if (!cmd[0]) { diff --git a/lib/Utils/CommLayerInner.cpp b/lib/Utils/CommLayerInner.cpp index 133e97d..4a3b80a 100644 --- a/lib/Utils/CommLayerInner.cpp +++ b/lib/Utils/CommLayerInner.cpp @@ -68,11 +68,9 @@ void update_client(const char *fmt, ...) va_list p; va_start(p, fmt); - char *msg; - int used = vasprintf(&msg, fmt, p); + char *msg = xvasprintf(fmt, p); va_end(p); - if (used < 0) - return; s_pObs->Status(msg, peer, key); + free(msg); } diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp index cb3a082..dd992aa 100644 --- a/lib/Utils/DebugDump.cpp +++ b/lib/Utils/DebugDump.cpp @@ -115,7 +115,15 @@ static bool GetAndSetLock(const char* pLockFile, const char* pPID) char pid_buf[sizeof(pid_t)*3 + 4]; ssize_t r = readlink(pLockFile, pid_buf, sizeof(pid_buf) - 1); if (r < 0) + { + if (errno == ENOENT) + { + /* Looks like pLockFile was deleted */ + usleep(10 * 1000); /* avoid CPU eating loop */ + continue; + } perror_msg_and_die("Can't read lock file '%s'", pLockFile); + } pid_buf[r] = '\0'; if (strcmp(pid_buf, pPID) == 0) @@ -228,7 +236,7 @@ void CDebugDump::UnLock() } } -void CDebugDump::Create(const char *pDir, int64_t uid) +void CDebugDump::Create(const char *pDir, uid_t uid) { if (m_bOpened) { diff --git a/lib/Utils/DebugDump.h b/lib/Utils/DebugDump.h index c59552e..ce515db 100644 --- a/lib/Utils/DebugDump.h +++ b/lib/Utils/DebugDump.h @@ -62,7 +62,7 @@ class CDebugDump ~CDebugDump(); void Open(const char *pDir); - void Create(const char *pDir, int64_t uid); + void Create(const char *pDir, uid_t uid); void Delete(); void Close(); diff --git a/lib/Utils/Polkit.cpp b/lib/Utils/Polkit.cpp index c868e1a..8bd0eb6 100644 --- a/lib/Utils/Polkit.cpp +++ b/lib/Utils/Polkit.cpp @@ -46,14 +46,12 @@ static PolkitResult do_check(PolkitSubject *subject, const char *action_id) GCancellable * cancellable; authority = polkit_authority_get(); - cancellable = g_cancellable_new(); g_timeout_add(POLKIT_TIMEOUT * 1000, (GSourceFunc) do_cancel, cancellable); - result = polkit_authority_check_authorization_sync(authority, subject, action_id, @@ -61,6 +59,7 @@ static PolkitResult do_check(PolkitSubject *subject, const char *action_id) POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, cancellable, &error); + g_object_unref(authority); if (error) { @@ -71,11 +70,18 @@ static PolkitResult do_check(PolkitSubject *subject, const char *action_id) if (result) { if (polkit_authorization_result_get_is_challenge(result)) + { /* Can't happen (happens only with * POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE flag) */ + g_object_unref(result); return PolkitChallenge; + } if (polkit_authorization_result_get_is_authorized(result)) + { + g_object_unref(result); return PolkitYes; + } + g_object_unref(result); return PolkitNo; } diff --git a/lib/Utils/xatonum.cpp b/lib/Utils/xatonum.cpp index b096ca8..8314629 100644 --- a/lib/Utils/xatonum.cpp +++ b/lib/Utils/xatonum.cpp @@ -9,7 +9,7 @@ unsigned xatou(const char *numstr) { - unsigned r; + unsigned long r; int old_errno; char *e; @@ -19,7 +19,7 @@ unsigned xatou(const char *numstr) old_errno = errno; errno = 0; r = strtoul(numstr, &e, 10); - if (errno || numstr == e || *e != '\0') + if (errno || numstr == e || *e != '\0' || r > UINT_MAX) goto inval; /* error / no digits / illegal trailing chars */ errno = old_errno; /* Ok. So restore errno. */ return r; diff --git a/src/Applet/CCApplet.cpp b/src/Applet/CCApplet.cpp index 07e44d8..770915a 100644 --- a/src/Applet/CCApplet.cpp +++ b/src/Applet/CCApplet.cpp @@ -205,7 +205,7 @@ void CApplet::CrashNotify(const char *format, ...) if (gtk_status_icon_is_embedded(m_pStatusIcon)) notify_notification_show(m_pNotification, &err); if (err != NULL) - error_msg(err->message); + error_msg("%s", err->message); } void CApplet::OnAppletActivate_CB(GtkStatusIcon *status_icon, gpointer user_data) diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index 88c058b..59f9e65 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -168,12 +168,11 @@ int CreateReportThread(const char* pUUID, const char* pUID, int force, const cha thread_data->force = force; thread_data->peer = xstrdup(pSender); -//TODO: do we need this? -//pthread_attr_t attr; -//pthread_attr_init(&attr); -//pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - - int r = pthread_create(&thread_data->thread_id, NULL, create_report, thread_data); + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + int r = pthread_create(&thread_data->thread_id, &attr, create_report, thread_data); + pthread_attr_destroy(&attr); if (r != 0) { free(thread_data->UUID); @@ -187,7 +186,6 @@ int CreateReportThread(const char* pUUID, const char* pUID, int force, const cha return r; } VERB3 log("Thread %llx created", (unsigned long long)thread_data->thread_id); -//pthread_attr_destroy(&attr); return r; } diff --git a/src/Daemon/abrt-debuginfo-install b/src/Daemon/abrt-debuginfo-install index cfae49a..35f4d6a 100755 --- a/src/Daemon/abrt-debuginfo-install +++ b/src/Daemon/abrt-debuginfo-install @@ -145,9 +145,11 @@ print_package_names() { fi # when we look for debuginfo we need only -debuginfo* repos, so we can disable the rest and thus make it faster # also we want only fedora repositories, because abrt won't work for other packages anyway - local cmd="yum $yumopts --disablerepo=* --enablerepo=fedora-debuginfo* --enablerepo=updates-debuginfo* --quiet provides $missing_debuginfo_files" + local cmd="yum $yumopts '--disablerepo=*' '--enablerepo=fedora-debuginfo*' '--enablerepo=updates-debuginfo*' --quiet provides $missing_debuginfo_files" echo "$cmd" >"yum_provides.$1.OUT" - local yum_provides_OUT="`$cmd 2>&1`" + # eval is needed to strip away ''s; cant remove them above and just use + # $cmd, that would perform globbing on '*' + local yum_provides_OUT="`eval $cmd 2>&1`" local err=$? printf "%s\nyum exitcode:%s\n" "$yum_provides_OUT" $err >>"yum_provides.$1.OUT" test $err = 0 || error_msg_and_die "yum provides... exited with $err: diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp index b09a132..b5bfff7 100644 --- a/src/Hooks/CCpp.cpp +++ b/src/Hooks/CCpp.cpp @@ -70,7 +70,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_DAEMON); + openlog("abrt", 0, 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 468c7ec..1a7eace 100644 --- a/src/Hooks/abrt-hook-python.cpp +++ b/src/Hooks/abrt-hook-python.cpp @@ -79,6 +79,8 @@ int main(int argc, char** argv) if (!pid || !executable || !uuid) goto usage; +//TODO: sanitize uuid and executable (size, valid chars etc) + unsigned setting_MaxCrashReportsSize = 0; parse_conf(NULL, &setting_MaxCrashReportsSize, NULL); if (setting_MaxCrashReportsSize > 0) |
