]> sourceware.org Git - debugedit.git/commit
Fix type mismatch calculating new line program offset in debugedit.c.
authorMark Wielaard <mark@klomp.org>
Mon, 22 Jan 2018 15:55:51 +0000 (16:55 +0100)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 1 Feb 2018 11:11:12 +0000 (13:11 +0200)
commita83472351c4aa9c9252daadcffcba876b4a9cf1c
tree056215a44cd6a758d132ebc9d3fc4fccf575a166
parentc2a8bd1c33016c3638cd38d691d6415b94becc19
Fix type mismatch calculating new line program offset in debugedit.c.

edit_dwarf2 calculates the (new) offset in the line program by
taking the difference between the old and new idx, which are of type
size_t (unsigned), plus the size_diff of the header given as ssize_t
(signed), and adding that to the current r_offset, which is an Elf64_Addr
(unsigned). On 64bit architectures, where the size of Elf64_Addr and
ssize_t are the same this isn't a problem. But on 32bit architectures,
where the size of ssize_t is smaller than Elf64_Addr the smaller signed
result gets promoted to an unsigned long first causing issues if the
size_diff was negative.

This would have been caught by gcc -Wsign-conversion

warning: conversion to ‘long unsigned int’ from ‘ssize_t’ {aka ‘long int’}
may change the sign of the result

But enabling this by default gives a lot of false positives.

Found and fixed by Richard Biener <rguenther@suse.de>.
tools/debugedit.c
This page took 0.024093 seconds and 5 git commands to generate.