djhenderson / pefile

Automatically exported from code.google.com/p/pefile
Other
0 stars 0 forks source link

possible section_alignment bug? #54

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Review the source code
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.
Reviewing the section alignment code it looks like there is a bug.

It will always return val.

        if section_alignment and val % section_alignment:
            return section_alignment * ( val / section_alignment )
        return val

Probably should be:

        if section_alignment and val % section_alignment:
            return section_alignment * (( val / section_alignment ) + 1)
        return val

Original issue reported on code.google.com by slw07g...@gmail.com on 22 Oct 2014 at 6:02

GoogleCodeExporter commented 9 years ago
Hi, in Python 2.x the division (val / section_alignment) is a floor division 
(because both numbers are int) hence the subsequent multiplication will yield 
an integer multiple of section_alignment, as expected.

Original comment by ero.carr...@gmail.com on 27 Oct 2014 at 3:02