summaryrefslogtreecommitdiff
path: root/ftparchive
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-10-05 18:43:00 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-10-05 18:43:00 +0200
commit0fffbc8ce4cb6357f59db63db5571f46a668a66b (patch)
tree2d691473c05b86c9fd78229fd9edbe4e2ee6ee3a /ftparchive
parent39fb1e241ebb76c7e51c8d8f2f76ce5f1e680859 (diff)
parent7be8c02360bdb9bd7f59b087da874f88af2a7206 (diff)
downloadapt-0fffbc8ce4cb6357f59db63db5571f46a668a66b.tar.gz
merge with current debian apt/experimental
Diffstat (limited to 'ftparchive')
-rw-r--r--ftparchive/cachedb.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/ftparchive/cachedb.cc b/ftparchive/cachedb.cc
index c4db88811..f0bfa2a6d 100644
--- a/ftparchive/cachedb.cc
+++ b/ftparchive/cachedb.cc
@@ -300,11 +300,15 @@ bool CacheDB::LoadContents(bool const &GenOnly)
/*}}}*/
static std::string bytes2hex(uint8_t *bytes, size_t length) {
- char space[65];
- if (length * 2 > sizeof(space) - 1) length = (sizeof(space) - 1) / 2;
- for (size_t i = 0; i < length; i++)
- snprintf(&space[i*2], 3, "%02x", bytes[i]);
- return std::string(space);
+ char buf[3];
+ std::string space;
+
+ space.reserve(length*2 + 1);
+ for (size_t i = 0; i < length; i++) {
+ snprintf(buf, sizeof(buf), "%02x", bytes[i]);
+ space.append(buf);
+ }
+ return space;
}
static inline unsigned char xdig2num(char const &dig) {