summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorjoerg <joerg>2006-08-29 13:43:11 +0000
committerjoerg <joerg>2006-08-29 13:43:11 +0000
commit6045aef55e40212816ac21e8cacceb0b6bc167fd (patch)
tree767a8d59f5b307dd001f48c8e8619a2e3a4bd6ef /pkgtools
parent29e3940bea381c3e4355338c679a9804a292015d (diff)
downloadpkgsrc-6045aef55e40212816ac21e8cacceb0b6bc167fd.tar.gz
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 (limited to 'pkgtools')
-rw-r--r--pkgtools/digest/Makefile6
-rwxr-xr-xpkgtools/digest/files/configure18
-rw-r--r--pkgtools/digest/files/configure.ac4
-rw-r--r--pkgtools/digest/files/regress.sh14
-rw-r--r--pkgtools/digest/files/tiger.c38
-rw-r--r--pkgtools/digest/files/whirlpool.c43
6 files changed, 57 insertions, 66 deletions
diff --git a/pkgtools/digest/Makefile b/pkgtools/digest/Makefile
index 49b1c7418b5..9093779469d 100644
--- a/pkgtools/digest/Makefile
+++ b/pkgtools/digest/Makefile
@@ -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 @@ do-test:
@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 --git a/pkgtools/digest/files/configure b/pkgtools/digest/files/configure
index 2d80f722b62..fccf19849e2 100755
--- a/pkgtools/digest/files/configure
+++ b/pkgtools/digest/files/configure
@@ -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>.
#
@@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# 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'
ac_unique_file="digest.c"
@@ -780,7 +780,7 @@ if test "$ac_init_help" = "long"; then
# 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 @@ fi
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 @@ fi
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 @@ cat >&5 <<_ACEOF
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 @@ _ASBOX
} >&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 @@ _ACEOF
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 --git a/pkgtools/digest/files/configure.ac b/pkgtools/digest/files/configure.ac
index 9460f302460..717256cef8d 100644
--- a/pkgtools/digest/files/configure.ac
+++ b/pkgtools/digest/files/configure.ac
@@ -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])
+AC_INIT([nbsd-digest],[20060826],[agc@netbsd.org])
AC_CONFIG_SRCDIR([digest.c])
AC_CONFIG_HEADER(config.h)
AC_ARG_PROGRAM
diff --git a/pkgtools/digest/files/regress.sh b/pkgtools/digest/files/regress.sh
index f53154bf58f..921992310c6 100644
--- a/pkgtools/digest/files/regress.sh
+++ b/pkgtools/digest/files/regress.sh
@@ -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 @@ diff expected6 output6 || echo "*** WARNING: output differs in test 6 (tiger) **
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 --git a/pkgtools/digest/files/tiger.c b/pkgtools/digest/files/tiger.c
index 37a401b8410..f45180f11dc 100644
--- a/pkgtools/digest/files/tiger.c
+++ b/pkgtools/digest/files/tiger.c
@@ -714,25 +714,30 @@ TIGERFinal(uint8_t *digest, tiger_context_t *tp)
/* 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 @@ TIGERFile(char *filename, char *buf)
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 @@ TIGERData(const uint8_t *data, size_t len, char *buf)
{
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 --git a/pkgtools/digest/files/whirlpool.c b/pkgtools/digest/files/whirlpool.c
index 7ba78f89a9d..437106e2e7c 100644
--- a/pkgtools/digest/files/whirlpool.c
+++ b/pkgtools/digest/files/whirlpool.c
@@ -1612,13 +1612,22 @@ whirlpool_finalize(unsigned char *result, whirlpool_context_t *structpointer)
}
+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_end(whirlpool_context_t *tp, char *buf)
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 @@ whirlpool_file(char *filename, char *buf)
int fd;
int num;
int oerrno;
-
- if (filename == NULL) {
- (void) fprintf(stderr, "NULL filename\n");
- return NULL;
- }
whirlpool_init(&ctx);