]> git.saurik.com Git - apt.git/blobdiff - ftparchive/cachedb.cc
merge with current debian apt/experimental
[apt.git] / ftparchive / cachedb.cc
index c4db88811d1b29195e2ed55aa8300dcea419fa08..f0bfa2a6d613cc4ae54c47a5c0e7ba80c79c54a3 100644 (file)
@@ -300,11 +300,15 @@ bool CacheDB::LoadContents(bool const &GenOnly)
                                                                        /*}}}*/
 
 static std::string bytes2hex(uint8_t *bytes, size_t length) {
                                                                        /*}}}*/
 
 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) {
 }
 
 static inline unsigned char xdig2num(char const &dig) {