Messages in this thread | | | Date | Fri, 31 Oct 2014 09:14:39 -0700 | Subject | Re: [PATCH] x86, kaslr: Prevent .bss from overlaping initrd | From | Kees Cook <> |
| |
On Fri, Oct 31, 2014 at 12:20 AM, Eternal <eternal.n08@gmail.com> wrote: > Kees Cook <keescook@chromium.org> writes: > I use the following function to print an arbitrary number in hexadecimal > in aslr.c and misc.c: > > void print_hex(unsigned long value) { > char c[2]; > int i; > > c[1] = '\0'; > for (i = 60; i >= 0; i -= 4) { > unsigned long digit = (addr >> i) & 0xf; > if (digit <= 9) { > c[0] = '0' + digit; > } else { > c[0] = 'a' + (digit - 10); > } > debug_putstr(c); > } > }
Hah! Yes, this is nearly line-for-line identical to a similar function I wrote when debugging kASLR during its development. :) I had asked because I was hoping I wasn't missing some existing way to print hex values. :)
I will send that, since we clearly keep needing this functionality.
>> Should mkpiggy.c do the work itself instead of taking an argument? > > Both ways are ok to me. I'm not sure which way is better, though.
Yeah, after spending time looking at it, your way seemed the cleanest.
-Kees
-- Kees Cook Chrome OS Security
| |