pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/pkg_install-renovation]: pkgsrc/pkgtools/pkg_install/files/lib Avoid ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/8104e2b23835
branches:  pkg_install-renovation
changeset: 541535:8104e2b23835
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Fri May 09 00:49:38 2008 +0000

description:
Avoid using SHA512_End. OpenSSL provides the other SHA512_* functions,
but not this one and mixing implementations results in very strange
errors.

diffstat:

 pkgtools/pkg_install/files/lib/vulnerabilities-file.c |  22 +++++++++++++++++-
 1 files changed, 20 insertions(+), 2 deletions(-)

diffs (41 lines):

diff -r 4c55179d2aad -r 8104e2b23835 pkgtools/pkg_install/files/lib/vulnerabilities-file.c
--- a/pkgtools/pkg_install/files/lib/vulnerabilities-file.c     Thu May 08 23:34:27 2008 +0000
+++ b/pkgtools/pkg_install/files/lib/vulnerabilities-file.c     Fri May 09 00:49:38 2008 +0000
@@ -36,7 +36,7 @@
 #if HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
-__RCSID("$NetBSD: vulnerabilities-file.c,v 1.3.4.1 2008/05/08 23:34:27 joerg Exp $");
+__RCSID("$NetBSD: vulnerabilities-file.c,v 1.3.4.2 2008/05/09 00:49:38 joerg Exp $");
 
 #if HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -122,9 +122,27 @@
 sha512_hash_finish(void *ctx)
 {
        static char hash[SHA512_DIGEST_STRING_LENGTH];
+       unsigned char digest[SHA512_DIGEST_LENGTH];
        SHA512_CTX *hash_ctx = ctx;
+       int i;
+
+       SHA512_Final(digest, hash_ctx);
+       for (i = 0; i < SHA512_DIGEST_LENGTH; ++i) {
+               unsigned char c;
 
-       SHA512_End(hash_ctx, hash);
+               c = digest[i] / 16;
+               if (c < 10)
+                       hash[2 * i] = '0' + c;
+               else
+                       hash[2 * i] = 'a' - 10 + c;
+
+               c = digest[i] % 16;
+               if (c < 10)
+                       hash[2 * i + 1] = '0' + c;
+               else
+                       hash[2 * i + 1] = 'a' - 10 + c;
+       }
+       hash[2 * i] = '\0';
 
        return hash;
 }



Home | Main Index | Thread Index | Old Index