Mon Sep 4 19:51:19 2023 UTC ()
libnbcompat: Update to 20230904.

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.


(jperkin)
diff -r1.90 -r1.91 pkgsrc/pkgtools/libnbcompat/Makefile
diff -r1.27 -r1.28 pkgsrc/pkgtools/libnbcompat/files/README
diff -r1.8 -r1.9 pkgsrc/pkgtools/libnbcompat/files/sha2.c

cvs diff -r1.90 -r1.91 pkgsrc/pkgtools/libnbcompat/Makefile (expand / switch to unified diff)

--- pkgsrc/pkgtools/libnbcompat/Makefile 2023/06/27 09:31:09 1.90
+++ pkgsrc/pkgtools/libnbcompat/Makefile 2023/09/04 19:51:19 1.91
@@ -1,22 +1,21 @@ @@ -1,22 +1,21 @@
1# $NetBSD: Makefile,v 1.90 2023/06/27 09:31:09 riastradh Exp $ 1# $NetBSD: Makefile,v 1.91 2023/09/04 19:51:19 jperkin Exp $
2# 2#
3# NOTE: If you update this package, it is *mandatory* that you update 3# NOTE: If you update this package, it is *mandatory* that you update
4# pkgsrc/pkgtools/libnbcompat/files/README to reflect the actual 4# pkgsrc/pkgtools/libnbcompat/files/README to reflect the actual
5# list of tested and supported platforms. 5# list of tested and supported platforms.
6# 6#
7 7
8PKGNAME= libnbcompat-20230609 8PKGNAME= libnbcompat-20230904
9PKGREVISION= 1 
10CATEGORIES= pkgtools devel 9CATEGORIES= pkgtools devel
11 10
12MAINTAINER= pkgsrc-users@NetBSD.org 11MAINTAINER= pkgsrc-users@NetBSD.org
13HOMEPAGE= https://www.NetBSD.org/ 12HOMEPAGE= https://www.NetBSD.org/
14COMMENT= Portable NetBSD compatibility library 13COMMENT= Portable NetBSD compatibility library
15 14
16GNU_CONFIGURE= yes 15GNU_CONFIGURE= yes
17MAKE_ENV+= LIBMODE=${LIBMODE} 16MAKE_ENV+= LIBMODE=${LIBMODE}
18 17
19# Enable by default for standalone builds 18# Enable by default for standalone builds
20CONFIGURE_ARGS+= --enable-db 19CONFIGURE_ARGS+= --enable-db
21 20
22do-extract: 21do-extract:

cvs diff -r1.27 -r1.28 pkgsrc/pkgtools/libnbcompat/files/README (expand / switch to unified diff)

--- pkgsrc/pkgtools/libnbcompat/files/README 2023/06/27 09:31:09 1.27
+++ pkgsrc/pkgtools/libnbcompat/files/README 2023/09/04 19:51:19 1.28
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1$NetBSD: README,v 1.27 2023/06/27 09:31:09 riastradh Exp $ 1$NetBSD: README,v 1.28 2023/09/04 19:51:19 jperkin Exp $
2 2
3 0 Introduction 3 0 Introduction
4 ============== 4 ==============
5 5
6libnbcompat builds and installs a portable NetBSD-compatibility library 6libnbcompat builds and installs a portable NetBSD-compatibility library
7that supplies routines missing on operating systems that are used by 7that supplies routines missing on operating systems that are used by
8the family of pkgsrc bootstrap tools. Note that libnbcompat is very 8the family of pkgsrc bootstrap tools. Note that libnbcompat is very
9much a work-in-progress. Only the functions that are directly used 9much a work-in-progress. Only the functions that are directly used
10by the bootstrap tools are implemented in the library. At the moment, 10by the bootstrap tools are implemented in the library. At the moment,
11this includes the following packages: 11this includes the following packages:
12 12
13 archivers/pax 13 archivers/pax
14 pkgtools/mtree 14 pkgtools/mtree
@@ -34,26 +34,33 @@ breakage seep in. Proper methodology fo @@ -34,26 +34,33 @@ breakage seep in. Proper methodology fo
34 34
35 (3) Fix any breakage on non-NetBSD operating systems before 35 (3) Fix any breakage on non-NetBSD operating systems before
36 committing. 36 committing.
37 37
38 38
39 2 Tested operating systems 39 2 Tested operating systems
40 ========================== 40 ==========================
41 41
42*NOTE* 42*NOTE*
43*NOTE* This section should be kept up-to-date with the results for 43*NOTE* This section should be kept up-to-date with the results for
44*NOTE* the most recent libnbcompat. 44*NOTE* the most recent libnbcompat.
45*NOTE* 45*NOTE*
46 46
 47libnbcompat-20230904 has been tested to build and install correctly
 48on the following operating systems:
 49
 50 Darwin-22.6.0-aarch64 <jperkin@pkgsrc.org>
 51 SunOS-5.11-i386 <jperkin@pkgsrc.org>
 52 SunOS-5.11-x86_64 <jperkin@pkgsrc.org>
 53
47libnbcompat-20230609 has been tested to build and install correctly 54libnbcompat-20230609 has been tested to build and install correctly
48on the following operating systems: 55on the following operating systems:
49 56
50 NetBSD/amd64 9.2 <riastradh@NetBSD.org> 57 NetBSD/amd64 9.2 <riastradh@NetBSD.org>
51 58
52libnbcompat-20200524 has been tested to build and install correctly 59libnbcompat-20200524 has been tested to build and install correctly
53on the following operating systems: 60on the following operating systems:
54 61
55 NetBSD/amd64 9.0 <nia@NetBSD.org> 62 NetBSD/amd64 9.0 <nia@NetBSD.org>
56 Alpine Linux 3.11.6 x86_64 <nia@NetBSD.org> 63 Alpine Linux 3.11.6 x86_64 <nia@NetBSD.org>
57 IRIX 6.5.22, mipspro 7.4.3 <ky0ko@disroot.org>  64 IRIX 6.5.22, mipspro 7.4.3 <ky0ko@disroot.org>
58 65
59libnbcompat-20190608 has been tested to build and install correctly 66libnbcompat-20190608 has been tested to build and install correctly

cvs diff -r1.8 -r1.9 pkgsrc/pkgtools/libnbcompat/files/sha2.c (expand / switch to unified diff)

--- pkgsrc/pkgtools/libnbcompat/files/sha2.c 2011/11/08 18:20:03 1.8
+++ pkgsrc/pkgtools/libnbcompat/files/sha2.c 2023/09/04 19:51:19 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sha2.c,v 1.8 2011/11/08 18:20:03 joerg Exp $ */ 1/* $NetBSD: sha2.c,v 1.9 2023/09/04 19:51:19 jperkin Exp $ */
2/* $KAME: sha2.c,v 1.9 2003/07/20 00:28:38 itojun Exp $ */ 2/* $KAME: sha2.c,v 1.9 2003/07/20 00:28:38 itojun Exp $ */
3 3
4/* 4/*
5 * sha2.c 5 * sha2.c
6 * 6 *
7 * Version 1.0.0beta1 7 * Version 1.0.0beta1
8 * 8 *
9 * Written by Aaron D. Gifford <me@aarongifford.com> 9 * Written by Aaron D. Gifford <me@aarongifford.com>
10 * 10 *
11 * Copyright 2000 Aaron D. Gifford. All rights reserved. 11 * Copyright 2000 Aaron D. Gifford. All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions 14 * modification, are permitted provided that the following conditions
@@ -558,27 +558,28 @@ void SHA256_Final(sha2_byte digest[], SH @@ -558,27 +558,28 @@ void SHA256_Final(sha2_byte digest[], SH
558 SHA256_Transform(context, (sha2_word32*)(void *)context->buffer); 558 SHA256_Transform(context, (sha2_word32*)(void *)context->buffer);
559 559
560 /* And set-up for the last transform: */ 560 /* And set-up for the last transform: */
561 memset(context->buffer, 0, (size_t)(SHA256_SHORT_BLOCK_LENGTH)); 561 memset(context->buffer, 0, (size_t)(SHA256_SHORT_BLOCK_LENGTH));
562 } 562 }
563 } else { 563 } else {
564 /* Set-up for the last transform: */ 564 /* Set-up for the last transform: */
565 memset(context->buffer, 0, (size_t)(SHA256_SHORT_BLOCK_LENGTH)); 565 memset(context->buffer, 0, (size_t)(SHA256_SHORT_BLOCK_LENGTH));
566 566
567 /* Begin padding with a 1 bit: */ 567 /* Begin padding with a 1 bit: */
568 *context->buffer = 0x80; 568 *context->buffer = 0x80;
569 } 569 }
570 /* Set the bit count: */ 570 /* Set the bit count: */
571 *(sha2_word64*)(void *)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount; 571 memcpy(&context->buffer[SHA256_SHORT_BLOCK_LENGTH],
 572 &context->bitcount, sizeof(context->bitcount));
572 573
573 /* Final transform: */ 574 /* Final transform: */
574 SHA256_Transform(context, (sha2_word32*)(void *)context->buffer); 575 SHA256_Transform(context, (sha2_word32*)(void *)context->buffer);
575 576
576#if BYTE_ORDER == LITTLE_ENDIAN 577#if BYTE_ORDER == LITTLE_ENDIAN
577 { 578 {
578 /* Convert TO host byte order */ 579 /* Convert TO host byte order */
579 int j; 580 int j;
580 for (j = 0; j < 8; j++) { 581 for (j = 0; j < 8; j++) {
581 REVERSE32(context->state[j],context->state[j]); 582 REVERSE32(context->state[j],context->state[j]);
582 *d++ = context->state[j]; 583 *d++ = context->state[j];
583 } 584 }
584 } 585 }
@@ -861,28 +862,30 @@ static void SHA512_Last(SHA512_CTX* cont @@ -861,28 +862,30 @@ static void SHA512_Last(SHA512_CTX* cont
861 SHA512_Transform(context, (sha2_word64*)(void *)context->buffer); 862 SHA512_Transform(context, (sha2_word64*)(void *)context->buffer);
862 863
863 /* And set-up for the last transform: */ 864 /* And set-up for the last transform: */
864 memset(context->buffer, 0, (size_t)(SHA512_BLOCK_LENGTH - 2)); 865 memset(context->buffer, 0, (size_t)(SHA512_BLOCK_LENGTH - 2));
865 } 866 }
866 } else { 867 } else {
867 /* Prepare for final transform: */ 868 /* Prepare for final transform: */
868 memset(context->buffer, 0, (size_t)(SHA512_SHORT_BLOCK_LENGTH)); 869 memset(context->buffer, 0, (size_t)(SHA512_SHORT_BLOCK_LENGTH));
869 870
870 /* Begin padding with a 1 bit: */ 871 /* Begin padding with a 1 bit: */
871 *context->buffer = 0x80; 872 *context->buffer = 0x80;
872 } 873 }
873 /* Store the length of input data (in bits): */ 874 /* Store the length of input data (in bits): */
874 *(sha2_word64*)(void *)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1]; 875 memcpy(&context->buffer[SHA512_SHORT_BLOCK_LENGTH],
875 *(sha2_word64*)(void *)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0]; 876 &context->bitcount[1], sizeof(context->bitcount[1]));
 877 memcpy(&context->buffer[SHA512_SHORT_BLOCK_LENGTH + 8],
 878 &context->bitcount[0], sizeof(context->bitcount[0]));
876 879
877 /* Final transform: */ 880 /* Final transform: */
878 SHA512_Transform(context, (sha2_word64*)(void *)context->buffer); 881 SHA512_Transform(context, (sha2_word64*)(void *)context->buffer);
879} 882}
880 883
881void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) { 884void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
882 sha2_word64 *d = (void *)digest; 885 sha2_word64 *d = (void *)digest;
883 886
884 /* Sanity check: */ 887 /* Sanity check: */
885 assert(context != (SHA512_CTX*)0); 888 assert(context != (SHA512_CTX*)0);
886 889
887 /* If no digest buffer is passed, we don't bother doing this: */ 890 /* If no digest buffer is passed, we don't bother doing this: */
888 if (digest != (sha2_byte*)0) { 891 if (digest != (sha2_byte*)0) {