]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
nastybad fencepost error if the input size is [60,63] mod 64
authorMarc Horowitz <marc@mit.edu>
Sun, 16 Aug 1998 03:37:10 +0000 (03:37 +0000)
committerMarc Horowitz <marc@mit.edu>
Sun, 16 Aug 1998 03:37:10 +0000 (03:37 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/branches/marc-3des@10827 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/crypto/sha1/shs.c

index e18f3af9e29bb61a9558389dc2a22d4fbf186927..a5b5a53d58821db7def7c3d0043c88be2865f18d 100644 (file)
@@ -376,15 +376,23 @@ void shsFinal(shsInfo)
        *lp++ = (LONG) 0x80 << 24;
     }
 
-    if (lp > shsInfo->data + 14) {
-       /* Pad out to 64 bytes if not enough room for length words */
-       *lp = 0;
+    /* at this point, lp can point *past* shsInfo->data.  If it points
+       there, just Transform and reset.  If it points to the last
+       element, set that to zero.  This pads out to 64 bytes if not
+       enough room for length words */
+
+    if (lp == shsInfo->data + 15)
+       *lp++ = 0;
+
+    if (lp == shsInfo->data + 16) {
        SHSTransform(shsInfo->digest, shsInfo->data);
        lp = shsInfo->data;
     }
+
     /* Pad out to 56 bytes */
     while (lp < shsInfo->data + 14)
        *lp++ = 0;
+
     /* Append length in bits and transform */
     *lp++ = shsInfo->countHi;
     *lp++ = shsInfo->countLo;