From: "Martin Liška" <mliska@suse.cz>
To: Ian Lance Taylor <iant@golang.org>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] libbacktrace: fix UBSAN issues
Date: Fri, 12 Nov 2021 15:07:58 +0100 [thread overview]
Message-ID: <423bd02b-c9e1-f6da-92e7-18a84bf3357b@suse.cz> (raw)
In-Reply-To: <CAKOQZ8xudfPxSMmmm9M-hdsFV6CFdcu4h49Gti6Z=KB1Joib+w@mail.gmail.com>
On 11/11/21 20:21, Ian Lance Taylor wrote:
> On Thu, Nov 11, 2021 at 7:39 AM Martin Liška <mliska@suse.cz> wrote:
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>
>> Ready to be installed?
>> Thanks,
>> Martin
>>
>> Fix issues mentioned in the PR.
>>
>> PR libbacktrace/103167
>>
>> libbacktrace/ChangeLog:
>>
>> * elf.c (elf_uncompress_lzma_block): Cast to unsigned int.
>> (elf_uncompress_lzma): Likewise.
>> * xztest.c (test_samples): memcpy only if v > 0.
>>
>> Co-Authored-By: Andrew Pinski <apinski@marvell.com>
>> ---
>> libbacktrace/elf.c | 8 ++++----
>> libbacktrace/xztest.c | 2 +-
>> 2 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
>> index 79d56146fc6..e69ac41c88b 100644
>> --- a/libbacktrace/elf.c
>> +++ b/libbacktrace/elf.c
>> @@ -3175,7 +3175,7 @@ elf_uncompress_lzma_block (const unsigned char *compressed,
>> stream_crc = (compressed[off]
>> | (compressed[off + 1] << 8)
>> | (compressed[off + 2] << 16)
>> - | (compressed[off + 3] << 24));
>> + | ((unsigned)(compressed[off + 3]) << 24));
>
> Thanks, but this kind of thing looks strange and is therefore likely
> to break again in the future. I suggest instead
>
> stream_crc = ((uint32_t) compressed[off]
> | ((uint32_t) compressed[off + 1] << 8)
> | ((uint32_t) compressed[off + 2] << 16)
> | ((uint32_t) compressed[off + 3] << 24));
>
> Same for the similar cases elsewhere.
Sure, done and pushed as g:83310a08a2bc52b6e8c3a3e3216b4e723e58c961.
Thanks,
Martin
>
> Ian
>
prev parent reply other threads:[~2021-11-12 14:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-11 15:38 Martin Liška
2021-11-11 19:21 ` Ian Lance Taylor
2021-11-12 14:07 ` Martin Liška [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=423bd02b-c9e1-f6da-92e7-18a84bf3357b@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=iant@golang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).