[packagekit] [PATCH] aptcc: Don't crash if spawning gdebi fails
Colin Watson
cjwatson at ubuntu.com
Mon Aug 5 05:31:21 PDT 2013
If the aptcc backend fails to spawn gdebi (as can happen if a plugin
declares that it can handle PK_ROLE_ENUM_INSTALL_FILES but then can't
handle all the provided files, or perhaps because of hitting a resource
limit or similar), dereferencing std_out and std_err is invalid and will
probably crash.
---
backends/aptcc/apt-intf.cpp | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/backends/aptcc/apt-intf.cpp b/backends/aptcc/apt-intf.cpp
index 78a8f35..cb5182a 100644
--- a/backends/aptcc/apt-intf.cpp
+++ b/backends/aptcc/apt-intf.cpp
@@ -2080,11 +2080,19 @@ bool AptIntf::markFileForInstall(const gchar *file, PkgList &install, PkgList &r
&gerror);
int exit_code = WEXITSTATUS(status);
// cout << "DebStatus " << exit_code << " WEXITSTATUS " << WEXITSTATUS(status) << " ret: "<< ret << endl;
- cout << "std_out " << strlen(std_out) << std_out << endl;
- cout << "std_err " << strlen(std_err) << std_err << endl;
+ if (ret) {
+ cout << "std_out " << strlen(std_out) << std_out << endl;
+ cout << "std_err " << strlen(std_err) << std_err << endl;
+ }
PkgList pkgs;
- if (exit_code == 1) {
+ if (!ret) {
+ pk_backend_job_error_code(m_job, PK_ERROR_ENUM_TRANSACTION_ERROR,
+ "Spawn of helper '%s' failed: %s",
+ argv[0], gerror->message);
+ g_error_free(gerror);
+ return false;
+ } else if (exit_code == 1) {
if (strlen(std_out) == 0) {
pk_backend_job_error_code(m_job, PK_ERROR_ENUM_TRANSACTION_ERROR, "Error: %s", std_err);
} else {
--
1.8.3.2
Thanks,
--
Colin Watson [cjwatson at ubuntu.com]
More information about the PackageKit
mailing list