Closed RinCat closed 2 years ago
The error only happened in -O2
.
x86_64-pc-linux-gnu-11.2.0
x86_64-gentoo-linux-musl-11.2.0
I found that this problem can also be reproduced under glibc, so the problem is in gcc 11.
Just before the line https://github.com/NLnetLabs/ldns/blob/4d2057f0b5220487882be1b19c302833b84cffe3/sha2.c#L601 The states are the same, but the last of a few bytes in buffer changed, and there is no corresponding code.
gcc (-O2
):
context.buffer [64]
0x3d 0xeb 0x95 0x9f 0x77 0x59 0xe0 0x48 0x84 0x84 0x7b 0x11 0xaf 0x69 0x12 0x80 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x07 0x27 0xdd 0x4a 0xba 0x35 0x90 0xd4
clang, and gcc(-O1
):
context.buffer [64]
0x3d 0xeb 0x95 0x9f 0x77 0x59 0xe0 0x48 0x84 0x84 0x7b 0x11 0xaf 0x69 0x12 0x80 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x02 0x78
Thanks @RinCat , I think your issue might be the same as in #131 Could you try compiling with -fno-strict-aliasing
?
@wtoorop Hi, I confirm use -fno-strict-aliasing
fixed it.
Also the commit https://github.com/NLnetLabs/ldns/commit/4d2057f0b5220487882be1b19c302833b84cffe3 works.
Resolved in ldns-1.8.0
Not sure what caused it, but the SHA256 result is wrong under gcc 11 (11.2). The SHA1 result is correct.
Example key:
Krincat.ch.+013+18046.key
:Under clang (12.0):
Under gcc (11.2):