]> git.saurik.com Git - apt.git/blobdiff - ftparchive/cachedb.cc
* apt-pkg/contrib/configuration.cc:
[apt.git] / ftparchive / cachedb.cc
index 699718e57b8c935efb78a2620092371a20c8fba0..6eccb8d4ae6f8f046e49bc5f30c85a99f230e0a9 100644 (file)
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#include "cachedb.h"
+#include <config.h>
 
-#include <apti18n.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/md5.h>
 #include <apt-pkg/sha1.h>
-#include <apt-pkg/sha256.h>
-#include <apt-pkg/sha512.h>
+#include <apt-pkg/sha2.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/configuration.h>
     
 #include <netinet/in.h>       // htonl, etc
+
+#include <apti18n.h>
+#include "cachedb.h"
                                                                        /*}}}*/
 
 // CacheDB::ReadyDB - Ready the DB2                                    /*{{{*/
@@ -298,11 +299,15 @@ bool CacheDB::LoadContents(bool const &GenOnly)
                                                                        /*}}}*/
 
 static 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 string(space);
+   char buf[3];
+   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) {