diff options
author | NotTsunami <4589807+NotTsunami@users.noreply.github.com> | 2020-09-04 11:31:58 -0400 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2021-03-15 13:46:20 +1100 |
commit | 5f5035d2093421c43770eb0f0628e2f60aea61a5 (patch) | |
tree | b34389de602112836c91a7e5891ac31dd4c60ec2 /src/flac/decode.c | |
parent | d7b33142ecb4e64b7eaf54564d6ad6e7f20a6c5d (diff) | |
download | flac-5f5035d2093421c43770eb0f0628e2f60aea61a5.tar.gz |
flac: Work around gcc bug to prevent false unset MD5 signature warning
A bug beginning in gcc version 9.2 causes strings to get incorrectly
stripped when passed directly to memcmp with a zero first byte (1).
This bug causes flac -t to fail on any .flac file with a md5 checksum
beginning in 00. To work around this bug, the FLAC__byte type is used
for an empty md5 sum to prevent a string from being stripped, which
is backwards compatible and avoids compile-time checks. This was
initially reported back in March 2020, but has seen more light since
Ubuntu 19.10 and up ship with gcc 9.2 as the default compiler. A
patch has been merged into the master gcc branch (2), but has not
been included in any versions as of this commit date.
The initial reporter provided a patch in their bug report (3), which
is included in this PR with authorship attributed to the reporter.
(1) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
(2) https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=d5803b9876b3d11c93d1a10fabb3fbb1c4a14bd6
(3) https://sourceforge.net/p/flac/bugs/478/
Closes #192.
Diffstat (limited to 'src/flac/decode.c')
-rw-r--r-- | src/flac/decode.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/flac/decode.c b/src/flac/decode.c index c26d3f60..1a8f28e9 100644 --- a/src/flac/decode.c +++ b/src/flac/decode.c @@ -1305,9 +1305,10 @@ void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMet FLAC__stream_decoder_get_decode_position(decoder, &decoder_session->decode_position); if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { + FLAC__byte emptyMD5[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; FLAC__uint64 skip, until; decoder_session->got_stream_info = true; - decoder_session->has_md5sum = memcmp(metadata->data.stream_info.md5sum, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16); + decoder_session->has_md5sum = memcmp(metadata->data.stream_info.md5sum, emptyMD5, 16); decoder_session->bps = metadata->data.stream_info.bits_per_sample; decoder_session->channels = metadata->data.stream_info.channels; decoder_session->sample_rate = metadata->data.stream_info.sample_rate; |