summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Nicoletti <dantti12@gmail.com>2012-04-20 03:18:02 -0300
committerDaniel Nicoletti <dantti12@gmail.com>2012-04-20 03:18:02 -0300
commit1a1852173d376ede81f2d873e53342232a32ce9c (patch)
treed23c43e1b0f7d127fa694179c2802c2952fbc1f4
parenteda735a08ac4e406b25bde278438382b2b92245f (diff)
aptcc: Avoid crashing when error messages containing invalid utf8 is sent
-rw-r--r--backends/aptcc/AptCacheFile.cpp4
-rw-r--r--backends/aptcc/apt-intf.cpp11
-rw-r--r--backends/aptcc/apt-messages.cpp9
-rw-r--r--backends/aptcc/pk-backend-aptcc.cpp7
4 files changed, 17 insertions, 14 deletions
diff --git a/backends/aptcc/AptCacheFile.cpp b/backends/aptcc/AptCacheFile.cpp
index f3548030..c4d5877c 100644
--- a/backends/aptcc/AptCacheFile.cpp
+++ b/backends/aptcc/AptCacheFile.cpp
@@ -19,6 +19,8 @@
*/
#include "AptCacheFile.h"
+#include "apt-utils.h"
+
#include <apt-pkg/algorithms.h>
#include <sstream>
#include <cstdio>
@@ -219,7 +221,7 @@ void AptCacheFile::ShowBroken(bool Now, PkErrorEnum error)
}
}
}
- pk_backend_error_code(m_backend, error, out.str().c_str());
+ pk_backend_error_code(m_backend, error, utf8(out.str().c_str()));
}
void AptCacheFile::buildPkgRecords()
diff --git a/backends/aptcc/apt-intf.cpp b/backends/aptcc/apt-intf.cpp
index 2217a69e..4389c8cd 100644
--- a/backends/aptcc/apt-intf.cpp
+++ b/backends/aptcc/apt-intf.cpp
@@ -102,6 +102,12 @@ bool AptIntf::init()
// Tries to open the cache
bool ret;
ret = m_cache.Open();
+
+ // Prepare for the restart thing
+ if (g_file_test(REBOOT_REQUIRED, G_FILE_TEST_EXISTS)) {
+ g_stat(REBOOT_REQUIRED, &m_restartStat);
+ }
+
return !ret;
}
@@ -2505,11 +2511,6 @@ bool AptIntf::installPackages(AptCacheFile &cache, bool simulating)
// Store the packages that are going to change
// so we can emit them as we process it
m_pkgs = checkChangedPackages(cache, false);
-
- // Prepare for the restart thing
- if (g_file_test(REBOOT_REQUIRED, G_FILE_TEST_EXISTS)) {
- g_stat(REBOOT_REQUIRED, &m_restartStat);
- }
}
pk_backend_set_status (m_backend, PK_STATUS_ENUM_DOWNLOAD);
diff --git a/backends/aptcc/apt-messages.cpp b/backends/aptcc/apt-messages.cpp
index 15e548ec..b95c0dee 100644
--- a/backends/aptcc/apt-messages.cpp
+++ b/backends/aptcc/apt-messages.cpp
@@ -22,6 +22,8 @@
#include "apt-messages.h"
+#include "apt-utils.h"
+
#include <string>
#include <sstream>
#include <cstdio>
@@ -54,12 +56,11 @@ bool show_errors(PkBackend *backend, PkErrorEnum errorCode, bool errModify)
}
if (!errors.str().empty()) {
- pk_backend_error_code(backend, errorCode, errors.str().c_str());
+ pk_backend_error_code(backend, errorCode, utf8(errors.str().c_str()));
}
if ((errModify) && (!messages.str().empty())) {
- cout << "Emitting backend message:" << messages.str() << endl;
- pk_backend_message(backend, messageCode, messages.str().c_str());
+ pk_backend_message(backend, messageCode, utf8(messages.str().c_str()));
}
}
@@ -78,6 +79,6 @@ bool show_warnings(PkBackend *backend, PkMessageEnum message)
}
if (!warnings.str().empty()) {
- pk_backend_message(backend, message, warnings.str().c_str());
+ pk_backend_message(backend, message, utf8(warnings.str().c_str()));
}
}
diff --git a/backends/aptcc/pk-backend-aptcc.cpp b/backends/aptcc/pk-backend-aptcc.cpp
index 9c190057..1a8b208d 100644
--- a/backends/aptcc/pk-backend-aptcc.cpp
+++ b/backends/aptcc/pk-backend-aptcc.cpp
@@ -681,11 +681,10 @@ static gboolean pk_backend_refresh_cache_thread(PkBackend *backend)
return false;
}
- // missing gpg signature would appear here
- // TODO we need a better enum
+ // missing repo gpg signature would appear here
if (_error->PendingError() == false && _error->empty() == false) {
- //show_warnings(backend, PK_MESSAGE_ENUM_UNTRUSTED_PACKAGE);
- //TODO: emit a package with PK_INFO_ENUM_UNTRUSTED
+ // TODO we need a repo warning
+ show_warnings(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR);
}
delete apt;