Comments (8)
It's possible the mtree in src has the same issue because the sha2.c
code in question is largely shared but -fno-strict-aliasing
is used in some places around the codebase so I'm not sure if it ends up being set when compiling sha2.c
. I'll boot up a NetBSD VM and take a look...
from pkgsrc.
Seems that NetBSD 10 will use GCC 10.5 and NetBSD 9.3 has GCC 7.5, so the issue is not present in current NetBSD (some quick testing in a NetBSD 9.3 VM shows that mtree
produces the correct output), but -fno-strict-aliasing
should still be set to make sure it isn't silently missed when a newer GCC version is added.
from pkgsrc.
cc @jsonn
from pkgsrc.
archiecobbs/libnbcompat@864c1cf is a patch in the Linux port which fixes the strict aliasing issue.
diff --git a/sha2.c b/sha2.c
index bdcbd317bdd4..4c9436f98275 100644
--- a/sha2.c
+++ b/sha2.c
@@ -567,7 +567,7 @@ void SHA256_Final(sha2_byte digest[SHA256_DIGEST_LENGTH], 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);
@@ -870,8 +870,8 @@ 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));
+ memcpy(&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8], &context->bitcount[0], sizeof(*context->bitcount));
/* Final transform: */
SHA512_Transform(context, (sha2_word64*)(void *)context->buffer);
from pkgsrc.
I'm pretty sure this was closed in error.
from pkgsrc.
Stupid GitHub auto-close.
from pkgsrc.
This looks akin to a fix already committed to our digest package:
b631703
In other words, quite reasonable for us to integrate.
from pkgsrc.
Related Issues (20)
- bind916 - removed _XOPEN_SOURCE - socket.c HOT 2
- mtree bugs with filenames containing wildcards HOT 6
- Bug/problem reporting: use GitHub or use GNATS ? HOT 2
- devel/cmake: CMake 3.22 not able to detect properly compiler on macOS Monterey HOT 8
- harfbuzz build fail on macOS afer upgrade Xcode to 13.3.0 (and 13.3.1)
- Unprivileged bootstrapping fails on Ubuntu 20.04: `ERROR: Circular dependency detected` HOT 2
- Can't build libstrophe because there is no PLIST file HOT 3
- Cross-compiling on Linux (native) for QNX (target) HOT 2
- Request to add tintin++ from pkgsrc-wip HOT 2
- cmake : build static linked executable failed HOT 2
- graphics/netpbm installation is failing on Ubuntu 22.04 HOT 1
- pkgtools/libnbcompat: unable to compile with GCC 11 (default compilers Ubuntu 22.04) HOT 2
- bootstrap failed on Artix Linux: ERROR: Circular dependency detected HOT 2
- bind external DNS zone config HOT 1
- man pages missing from graphics/colord/PLIST HOT 2
- zsh: segmentation fault hexchat
- bootstrapping on mac m1 HOT 2
- anyplans on regaining support for freebsd and fixing bootstrap for it HOT 7
- Can you add zlib-ng and minizip-ng packages?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pkgsrc.