summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-02-07 21:42:36 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-02-07 21:42:36 +0100
commit8f3853baea6191788da6befb437e92ba246c86a3 (patch)
tree6c3edf065be2c8eca709b57e4bcb74ff6b90f9d9
parentcfe35dbc01015c6927193fd5da02eaabd753989a (diff)
* apt-pkg/contrib/error.cc:
- remove 400 char size limit of error messages (LP: #365611)
-rw-r--r--apt-pkg/contrib/error.cc31
-rw-r--r--debian/changelog4
-rwxr-xr-xtest/integration/test-ubuntu-bug-365611-long-package-names11
3 files changed, 39 insertions, 7 deletions
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc
index e2e8d6e57..7dad11689 100644
--- a/apt-pkg/contrib/error.cc
+++ b/apt-pkg/contrib/error.cc
@@ -18,6 +18,7 @@
#include <iostream>
#include <errno.h>
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <string>
@@ -103,10 +104,21 @@ bool GlobalError::InsertErrno(MsgType const &type, const char *Function,
// GlobalError::InsertErrno - formats an error message with the errno /*{{{*/
bool GlobalError::InsertErrno(MsgType type, const char* Function,
const char* Description, va_list &args) {
- char S[400];
- snprintf(S, sizeof(S), "%s - %s (%i: %s)", Description,
- Function, errno, strerror(errno));
- return Insert(type, S, args);
+ int const errsv = errno;
+ char* S = (char*) malloc(400);
+ size_t const Ssize = snprintf(S, 400, "%s - %s (%i: %s)", Description,
+ Function, errsv, strerror(errsv)) + 1;
+
+ if (Ssize > 400) {
+ free(S);
+ S = (char*) malloc(Ssize);
+ snprintf(S, Ssize, "%s - %s (%i: %s)", Description,
+ Function, errsv, strerror(errsv));
+ }
+
+ bool const geins = Insert(type, S, args);
+ free(S);
+ return geins;
}
/*}}}*/
// GlobalError::Fatal - Add a fatal error to the list /*{{{*/
@@ -157,8 +169,14 @@ bool GlobalError::Insert(MsgType const &type, const char *Description,...)
// GlobalError::Insert - Insert a new item at the end /*{{{*/
bool GlobalError::Insert(MsgType type, const char* Description,
va_list &args) {
- char S[400];
- vsnprintf(S,sizeof(S),Description,args);
+ char* S = (char*) malloc(400);
+ size_t const Ssize = vsnprintf(S, 400, Description, args) + 1;
+
+ if (Ssize > 400) {
+ free(S);
+ S = (char*) malloc(Ssize);
+ vsnprintf(S, Ssize, Description, args);
+ }
Item const m(S, type);
Messages.push_back(m);
@@ -169,6 +187,7 @@ bool GlobalError::Insert(MsgType type, const char* Description,
if (type == FATAL || type == DEBUG)
std::clog << m << std::endl;
+ free(S);
return false;
}
/*}}}*/
diff --git a/debian/changelog b/debian/changelog
index 3adb9d76f..a44a603e3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -84,6 +84,8 @@ apt (0.8.11) UNRELEASED; urgency=low
* apt-pkg/pkgcachegen.cc:
- in multiarch, let :all packages conflict with :any packages
with a different version to be sure
+ * apt-pkg/contrib/error.cc:
+ - remove 400 char size limit of error messages (LP: #365611)
[ Michael Vogt ]
* methods/http.cc:
@@ -101,7 +103,7 @@ apt (0.8.11) UNRELEASED; urgency=low
will actually test uncompressed indexes regardless of the internal
default value of Acquire::GzipIndexes.
- -- David Kalnischkies <kalnischkies@gmail.com> Mon, 07 Feb 2011 13:06:50 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com> Mon, 07 Feb 2011 21:42:06 +0100
apt (0.8.10.3) unstable; urgency=low
diff --git a/test/integration/test-ubuntu-bug-365611-long-package-names b/test/integration/test-ubuntu-bug-365611-long-package-names
new file mode 100755
index 000000000..28b55df3b
--- /dev/null
+++ b/test/integration/test-ubuntu-bug-365611-long-package-names
@@ -0,0 +1,11 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture "i386"
+setupaptarchive
+
+aptget install $(for i in $(seq 0 1000); do echo -n 'a'; done) 2> longpackagename.log > /dev/null || true
+testfileequal 'longpackagename.log' "E: Unable to locate package $(for i in $(seq 0 1000); do echo -n 'a'; done)"