pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/digest Revert libncompat usage and kill the u...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/e8f398956911
branches:  trunk
changeset: 518029:e8f398956911
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Tue Aug 29 13:43:11 2006 +0000

description:
Revert libncompat usage and kill the use of snprintf in whirlpool and
tiger instead. Also kill bogus NULL pointer handling in both algorithms:
passing null pointers as buffers (when len != 0) or context is a serious
programming error and should result in a segfault. Bump version to
20060826. OK agc@

diffstat:

 pkgtools/digest/Makefile           |   6 +----
 pkgtools/digest/files/configure    |  18 +++++++-------
 pkgtools/digest/files/configure.ac |   4 +-
 pkgtools/digest/files/regress.sh   |  14 +++++++++++-
 pkgtools/digest/files/tiger.c      |  38 ++++++++++++++-------------------
 pkgtools/digest/files/whirlpool.c  |  43 ++++++++++++++-----------------------
 6 files changed, 57 insertions(+), 66 deletions(-)

diffs (278 lines):

diff -r 4a5c3ffff981 -r e8f398956911 pkgtools/digest/Makefile
--- a/pkgtools/digest/Makefile  Tue Aug 29 10:23:21 2006 +0000
+++ b/pkgtools/digest/Makefile  Tue Aug 29 13:43:11 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.50 2006/08/26 15:39:07 schwarz Exp $
+# $NetBSD: Makefile,v 1.51 2006/08/29 13:43:11 joerg Exp $
 #
 # When adding new digest algorithms, please use rmd160 as the template,
 # and bump the VERSION definition.
@@ -40,8 +40,4 @@
        @cd ${WRKSRC} && ${SETENV} DIGESTDIR=${WRKSRC} ${SH} ./regress.sh
        @${ECHO} "All tests completed"
 
-.if !empty(LOWER_OPSYS:Mirix5*)
-# digest uses snprintf()
-. include "../../pkgtools/libnbcompat/buildlink3.mk"
-.endif
 .include "../../mk/bsd.pkg.mk"
diff -r 4a5c3ffff981 -r e8f398956911 pkgtools/digest/files/configure
--- a/pkgtools/digest/files/configure   Tue Aug 29 10:23:21 2006 +0000
+++ b/pkgtools/digest/files/configure   Tue Aug 29 13:43:11 2006 +0000
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for nbsd-digest 20060302.
+# Generated by GNU Autoconf 2.59 for nbsd-digest 20060826.
 #
 # Report bugs to <agc%netbsd.org@localhost>.
 #
@@ -269,8 +269,8 @@
 # Identity of this package.
 PACKAGE_NAME='nbsd-digest'
 PACKAGE_TARNAME='nbsd-digest'
-PACKAGE_VERSION='20060302'
-PACKAGE_STRING='nbsd-digest 20060302'
+PACKAGE_VERSION='20060826'
+PACKAGE_STRING='nbsd-digest 20060826'
 PACKAGE_BUGREPORT='agc%netbsd.org@localhost'
 
 ac_unique_file="digest.c"
@@ -780,7 +780,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures nbsd-digest 20060302 to adapt to many kinds of systems.
+\`configure' configures nbsd-digest 20060826 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -846,7 +846,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of nbsd-digest 20060302:";;
+     short | recursive ) echo "Configuration of nbsd-digest 20060826:";;
    esac
   cat <<\_ACEOF
 
@@ -958,7 +958,7 @@
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
-nbsd-digest configure 20060302
+nbsd-digest configure 20060826
 generated by GNU Autoconf 2.59
 
 Copyright (C) 2003 Free Software Foundation, Inc.
@@ -972,7 +972,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by nbsd-digest $as_me 20060302, which was
+It was created by nbsd-digest $as_me 20060826, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   $ $0 $@
@@ -5890,7 +5890,7 @@
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by nbsd-digest $as_me 20060302, which was
+This file was extended by nbsd-digest $as_me 20060826, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5950,7 +5950,7 @@
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-nbsd-digest config.status 20060302
+nbsd-digest config.status 20060826
 configured by $0, generated by GNU Autoconf 2.59,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
diff -r 4a5c3ffff981 -r e8f398956911 pkgtools/digest/files/configure.ac
--- a/pkgtools/digest/files/configure.ac        Tue Aug 29 10:23:21 2006 +0000
+++ b/pkgtools/digest/files/configure.ac        Tue Aug 29 13:43:11 2006 +0000
@@ -1,7 +1,7 @@
-dnl $Id: configure.ac,v 1.7 2006/03/02 20:34:17 agc Exp $
+dnl $Id: configure.ac,v 1.8 2006/08/29 13:43:11 joerg Exp $
 dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.57)
-AC_INIT([nbsd-digest],[20060302],[agc%netbsd.org@localhost])
+AC_INIT([nbsd-digest],[20060826],[agc%netbsd.org@localhost])
 AC_CONFIG_SRCDIR([digest.c])
 AC_CONFIG_HEADER(config.h)
 AC_ARG_PROGRAM
diff -r 4a5c3ffff981 -r e8f398956911 pkgtools/digest/files/regress.sh
--- a/pkgtools/digest/files/regress.sh  Tue Aug 29 10:23:21 2006 +0000
+++ b/pkgtools/digest/files/regress.sh  Tue Aug 29 13:43:11 2006 +0000
@@ -1,7 +1,7 @@
 #! /bin/sh
 #
 # From
-# $NetBSD: regress.sh,v 1.3 2005/03/22 10:16:15 agc Exp $
+# $NetBSD: regress.sh,v 1.4 2006/08/29 13:43:11 joerg Exp $
 
 # one can do, for example to test with openssl: 
 #  DIGESTDIR=/path/to DIGESTCMD=openssl sh regress.sh
@@ -79,6 +79,18 @@
 
 rm -f expected6 output6
 
+cat > expected7 << EOF
+4e2448a4c6f486bb16b6562c73b4020bf3043e3a731bce721ae1b303d97e6d4c7181eebdb6c57e277d0e34957114cbd6c797fc9d95d8b582d225292076d4eef5
+526b2394d85683e24b29acd0fd37f7d5027f61366a1407262dc2a6a345d9e240c017c1833db1e6db6a46bd444b0c69520c856e7c6e9c366d150a7da3aeb160d1
+b37cde686c51c3970a1fb22959b6e5fe4bef90a5262e63126fabaddd0d0969783e1969459078fe7fcf7fdaa9ffbf6db80963296596169274c4a236bafeb95e7e
+EOF
+echo $ECHO_N "abc$ECHO_C" | ${DIGEST} whirlpool > output7
+echo $ECHO_N "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq$ECHO_C" | ${DIGEST} whirlpool >> output7
+echo $ECHO_N "Whirlpool - The Whirlpool hashing function.$ECHO_C" | ${DIGEST} whirlpool >> output7
+diff expected7 output7 || echo "*** WARNING: output differs in test 7 (whirlpool) ***"
+
+rm -f expected7 output7
+
 
 
 exit 0
diff -r 4a5c3ffff981 -r e8f398956911 pkgtools/digest/files/tiger.c
--- a/pkgtools/digest/files/tiger.c     Tue Aug 29 10:23:21 2006 +0000
+++ b/pkgtools/digest/files/tiger.c     Tue Aug 29 13:43:11 2006 +0000
@@ -714,25 +714,30 @@
        /* nothing to do - included for compatibility with SHA* interface */
 }
 
+static void
+print_uint64(char *buf, uint64_t val)
+{
+       int i = 0;
+       static const char hexdigits[] = "0123456789abcdef";
+
+       for (i = 0; i < 8; ++i) {
+               buf[2 * i] = hexdigits[(val >> (56 - 8 * i + 4)) & 15];
+               buf[2 * i + 1] = hexdigits[(val >> (56 - 8 * i)) & 15];
+       }
+}
+
 char *
 TIGEREnd(tiger_context_t *tp, char *buf)
 {   
-       if (tp == NULL) {
-               (void) fprintf(stderr, "NULL tiger_context_t\n");
-               return NULL;
-       }
+       int i;
 
        if (buf == NULL && (buf = malloc(41)) == NULL) {
                return NULL;
        }
 
-       (void) snprintf(buf, 49, "%08x%08x%08x%08x%08x%08x",
-               (uint32_t)(tp->ctx[0] >> 32),
-               (uint32_t)(tp->ctx[0]),
-               (uint32_t)(tp->ctx[1] >> 32),
-               (uint32_t)(tp->ctx[1]),
-               (uint32_t)(tp->ctx[2] >> 32),
-               (uint32_t)(tp->ctx[2]));
+       for (i = 0; i < 3; ++i)
+               print_uint64(buf + i * 16, tp->ctx[i]);
+       buf[16 * i] = '\0';
 
        return buf;
 }
@@ -747,11 +752,6 @@
        int             num;
        int             oerrno;
 
-       if (filename == NULL) {
-               (void) fprintf(stderr, "NULL filename\n");
-               return NULL;
-       }
-
        TIGERInit(&ctx);
 
        if ((fd = open(filename, O_RDONLY)) < 0) {
@@ -775,12 +775,6 @@
 {   
        tiger_context_t ctx;
 
-       /* XXX: buf may be NULL ? */
-       if (data == NULL) {
-               (void) fprintf(stderr, "TIGERData: NULL string\n");
-               return NULL;
-       }
-
        TIGERInit(&ctx);
        TIGERUpdate(&ctx, data, len);
        return(TIGEREnd(&ctx, buf));
diff -r 4a5c3ffff981 -r e8f398956911 pkgtools/digest/files/whirlpool.c
--- a/pkgtools/digest/files/whirlpool.c Tue Aug 29 10:23:21 2006 +0000
+++ b/pkgtools/digest/files/whirlpool.c Tue Aug 29 13:43:11 2006 +0000
@@ -1612,13 +1612,22 @@
 
 }
 
+static void
+print_uint64(char *buf, uint64_t val)
+{
+       int i = 0;
+       static const char hexdigits[] = "0123456789abcdef";
+
+       for (i = 0; i < 8; ++i) {
+               buf[2 * i] = hexdigits[(val >> (56 - 8 * i + 4)) & 15];
+               buf[2 * i + 1] = hexdigits[(val >> (56 - 8 * i)) & 15];
+       }
+}
+
 char *
 whirlpool_end(whirlpool_context_t *tp, char *buf)
 {   
-       if (tp == NULL) {
-               (void) fprintf(stderr, "NULL whirlpool_context_t\n");
-               return NULL;
-       }
+       int i;
 
        if (buf == NULL && (buf = malloc((2 * WHIRLPOOL_DIGEST_BYTES) + 1)) == NULL) {
                return NULL;
@@ -1626,24 +1635,9 @@
 
        whirlpool_finalize(buf, tp);
 
-       (void) snprintf(buf, (2 * WHIRLPOOL_DIGEST_BYTES) + 1,
-               "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x",
-               (uint32_t)(tp->hash[0] >> 32),
-               (uint32_t)(tp->hash[0]),
-               (uint32_t)(tp->hash[1] >> 32),
-               (uint32_t)(tp->hash[1]),
-               (uint32_t)(tp->hash[2] >> 32),
-               (uint32_t)(tp->hash[2]),
-               (uint32_t)(tp->hash[3] >> 32),
-               (uint32_t)(tp->hash[3]),
-               (uint32_t)(tp->hash[4] >> 32),
-               (uint32_t)(tp->hash[4]),
-               (uint32_t)(tp->hash[5] >> 32),
-               (uint32_t)(tp->hash[5]),
-               (uint32_t)(tp->hash[6] >> 32),
-               (uint32_t)(tp->hash[6]),
-               (uint32_t)(tp->hash[7] >> 32),
-               (uint32_t)(tp->hash[7]));
+       for (i = 0; i < 8; ++i)
+               print_uint64(buf + i * 16, tp->hash[i]);
+       buf[16 * i] = '\0';
 
        return buf;
 }
@@ -1667,11 +1661,6 @@
         int                    fd;
         int                    num;
         int                    oerrno;
-
-        if (filename == NULL) {
-                (void) fprintf(stderr, "NULL filename\n");
-                return NULL;
-        }
         
         whirlpool_init(&ctx);
         



Home | Main Index | Thread Index | Old Index