abg-dwarf-reader: zero initialize local Dwarf_Addr values
Commit Message
Not initializing those might lead to undefined behaviour. E.g. if the
call to 'dwarf_ranges' does not initialize 'addr', we pass that
uninitialized value to 'maybe_adjust_fn_sym_address' and test it for
zero as first action, depending on the random value. Hence, fix that by
initializing the values.
* src/abg-dwarf-reader.cc
(read_context::get_first_exported_fn_address_from_DW_AT_ranges):
initialize local Dwarf_Addr variables.
Signed-off-by: Matthias Maennich <maennich@google.com>
---
src/abg-dwarf-reader.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, Feb 04, 2020 at 09:38:22AM +0100, Dodji Seketeli wrote:
>Hello Matthias,
>
>Matthias Maennich <maennich@google.com> a ?crit:
>
>> Not initializing those might lead to undefined behaviour. E.g. if the
>> call to 'dwarf_ranges' does not initialize 'addr', we pass that
>> uninitialized value to 'maybe_adjust_fn_sym_address' and test it for
>> zero as first action, depending on the random value. Hence, fix that by
>> initializing the values.
>>
>> * src/abg-dwarf-reader.cc
>> (read_context::get_first_exported_fn_address_from_DW_AT_ranges):
>> initialize local Dwarf_Addr variables.
>
>This is OK to commit to master.
And done!
Cheers,
Matthias
>
>Thanks!
>
>--
> Dodji
Hello Matthias,
Matthias Maennich <maennich@google.com> a ?crit:
> Not initializing those might lead to undefined behaviour. E.g. if the
> call to 'dwarf_ranges' does not initialize 'addr', we pass that
> uninitialized value to 'maybe_adjust_fn_sym_address' and test it for
> zero as first action, depending on the random value. Hence, fix that by
> initializing the values.
>
> * src/abg-dwarf-reader.cc
> (read_context::get_first_exported_fn_address_from_DW_AT_ranges):
> initialize local Dwarf_Addr variables.
This is OK to commit to master.
Thanks!
@@ -8747,7 +8747,7 @@ public:
do
{
- Dwarf_Addr addr, fn_addr;
+ Dwarf_Addr addr = 0, fn_addr = 0;
if ((offset = dwarf_ranges(die, offset, &base, &addr, &end_addr)) >= 0)
{
fn_addr = maybe_adjust_fn_sym_address(addr);