Fix for #1 bump memsz to 8KB so that the scratch area used by hex2 doesn't get overwritten by brk (in theory bumping to 4KB would suffice, but 8KB gives a little more headroom). This only affected Linux 2.2 and 2.4 as those kernels do not seem to round up to the nearest 4KB boundry when the initial brk(0) call is make to read the initial value of brk. Because of this initial memory allocated by brk wil overlap the scratch area juts beyond the end of the hex2 binary (which then causes it to crash). eg before this patch we get a segfault on Linux 2.4. Using strace we can see that the first call to
…2 and 2.4 kernels
Fix for #1 bump memsz to 8KB so that the scratch area used by hex2 doesn't get overwritten by brk (in theory bumping to 4KB would suffice, but 8KB gives a little more headroom). This only affected Linux 2.2 and 2.4 as those kernels do not seem to round up to the nearest 4KB boundry when the initial brk(0) call is make to read the initial value of brk. Because of this initial memory allocated by brk wil overlap the scratch area juts beyond the end of the hex2 binary (which then causes it to crash). eg before this patch we get a segfault on Linux 2.4. Using strace we can see that the first call to
The above brk(0) value is 4 bytes after :table so allocated regions overlap and will cause memory corruption.