]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/sha1.cc
fix crash when P.Arch() was used but the cache got remapped
[apt.git] / apt-pkg / contrib / sha1.cc
index 9a6725ef394c1c8c0e8856b2c5191c086b3c77ac..5b9db202d0b2d161f36d00350e1424a6fc6db0ac 100644 (file)
@@ -74,10 +74,9 @@ static void SHA1Transform(uint32_t state[5],uint8_t const buffer[64])
       uint32_t l[16];
    }
    CHAR64LONG16;
-   CHAR64LONG16 *block;
+   CHAR64LONG16 workspace, *block;
 
-   uint8_t workspace[64];
-   block = (CHAR64LONG16 *)workspace;
+   block = &workspace;
    memcpy(block,buffer,sizeof(workspace));
 
    /* Copy context->state[] to working vars */
@@ -273,26 +272,3 @@ bool SHA1Summation::Add(const unsigned char *data,unsigned long len)
    return true;
 }
                                                                        /*}}}*/
-// SHA1Summation::AddFD - Add content of file into the checksum         /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool SHA1Summation::AddFD(int Fd,unsigned long Size)
-{
-   unsigned char Buf[64 * 64];
-   int Res = 0;
-   int ToEOF = (Size == 0);
-   while (Size != 0 || ToEOF)
-   {
-      unsigned n = sizeof(Buf);
-      if (!ToEOF) n = min(Size,(unsigned long)n);
-      Res = read(Fd,Buf,n);
-      if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
-        return false;
-      if (ToEOF && Res == 0) // EOF
-         break;
-      Size -= Res;
-      Add(Buf,Res);
-   }
-   return true;
-}
-                                                                       /*}}}*/