Skip to content

Commit

Permalink
libnbcompat: Update to 20230904.
Browse files Browse the repository at this point in the history
Pull in changes from revision 1.13 of NetBSD sha2.c from 14 years ago to
fix type punning issues seen with newer GCCs.

Fixes "pkg_admin digest" on SmartOS with GCC 12, where the output was
completely wrong, causing bulk builds to rebuild every package every time
now that USE_PKG_ADMIN_DIGEST=yes is the default.
  • Loading branch information
jperkin committed Sep 4, 2023
1 parent 3acd254 commit def71d1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
5 changes: 2 additions & 3 deletions pkgtools/libnbcompat/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# $NetBSD: Makefile,v 1.90 2023/06/27 09:31:09 riastradh Exp $
# $NetBSD: Makefile,v 1.91 2023/09/04 19:51:19 jperkin Exp $
#
# NOTE: If you update this package, it is *mandatory* that you update
# pkgsrc/pkgtools/libnbcompat/files/README to reflect the actual
# list of tested and supported platforms.
#

PKGNAME= libnbcompat-20230609
PKGREVISION= 1
PKGNAME= libnbcompat-20230904
CATEGORIES= pkgtools devel

MAINTAINER= pkgsrc-users@NetBSD.org
Expand Down
9 changes: 8 additions & 1 deletion pkgtools/libnbcompat/files/README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$NetBSD: README,v 1.27 2023/06/27 09:31:09 riastradh Exp $
$NetBSD: README,v 1.28 2023/09/04 19:51:19 jperkin Exp $

0 Introduction
==============
Expand Down Expand Up @@ -44,6 +44,13 @@ breakage seep in. Proper methodology for updating this package is:
*NOTE* the most recent libnbcompat.
*NOTE*

libnbcompat-20230904 has been tested to build and install correctly
on the following operating systems:

Darwin-22.6.0-aarch64 <jperkin@pkgsrc.org>
SunOS-5.11-i386 <jperkin@pkgsrc.org>
SunOS-5.11-x86_64 <jperkin@pkgsrc.org>

libnbcompat-20230609 has been tested to build and install correctly
on the following operating systems:

Expand Down
11 changes: 7 additions & 4 deletions pkgtools/libnbcompat/files/sha2.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: sha2.c,v 1.8 2011/11/08 18:20:03 joerg Exp $ */
/* $NetBSD: sha2.c,v 1.9 2023/09/04 19:51:19 jperkin Exp $ */
/* $KAME: sha2.c,v 1.9 2003/07/20 00:28:38 itojun Exp $ */

/*
Expand Down Expand Up @@ -568,7 +568,8 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
*context->buffer = 0x80;
}
/* Set the bit count: */
*(sha2_word64*)(void *)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
memcpy(&context->buffer[SHA256_SHORT_BLOCK_LENGTH],
&context->bitcount, sizeof(context->bitcount));

/* Final transform: */
SHA256_Transform(context, (sha2_word32*)(void *)context->buffer);
Expand Down Expand Up @@ -871,8 +872,10 @@ static void SHA512_Last(SHA512_CTX* context) {
*context->buffer = 0x80;
}
/* Store the length of input data (in bits): */
*(sha2_word64*)(void *)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1];
*(sha2_word64*)(void *)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0];
memcpy(&context->buffer[SHA512_SHORT_BLOCK_LENGTH],
&context->bitcount[1], sizeof(context->bitcount[1]));
memcpy(&context->buffer[SHA512_SHORT_BLOCK_LENGTH + 8],
&context->bitcount[0], sizeof(context->bitcount[0]));

/* Final transform: */
SHA512_Transform(context, (sha2_word64*)(void *)context->buffer);
Expand Down

0 comments on commit def71d1

Please sign in to comment.