]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Make hash_result() idempotent
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 18 Aug 2010 19:41:45 +0000 (21:41 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 18 Aug 2010 19:41:45 +0000 (21:41 +0200)
mdfour.c
mdfour.h

index 52c2fa02a601ed020f36a2ae7447c9665d14273e..541e8577275306939be732c9cd01babf16e53442 100644 (file)
--- a/mdfour.c
+++ b/mdfour.c
@@ -111,6 +111,7 @@ mdfour_begin(struct mdfour *md)
        md->D = 0x10325476;
        md->totalN = 0;
        md->tail_len = 0;
+       md->finalized = 0;
 }
 
 static
@@ -156,7 +157,10 @@ mdfour_update(struct mdfour *md, const unsigned char *in, size_t n)
        m = md;
 
        if (in == NULL) {
-               mdfour_tail(md->tail, md->tail_len);
+               if (!md->finalized) {
+                       mdfour_tail(md->tail, md->tail_len);
+                       md->finalized = 1;
+               }
                return;
        }
 
index 885ad830d83113acfb37e17dbb5e859b09fb81cd..c196a09e952ef7b164caa94d272ca031d02e32f4 100644 (file)
--- a/mdfour.h
+++ b/mdfour.h
@@ -9,6 +9,7 @@ struct mdfour {
        size_t totalN;
        unsigned char tail[64];
        size_t tail_len;
+       int finalized;
 };
 
 void mdfour_begin(struct mdfour *md);