Determining if an address is valid prior to using it.

Carlos O'Donell carlos@systemhalted.org
Thu Aug 7 03:41:00 GMT 2008


On Wed, Jul 23, 2008 at 4:06 PM,  <jimmie.davis@l-3com.com> wrote:
> Given an arbitrary address, is it possible to test and see if it is in
> the process's address space ?
>
> My current technique is to create a new thread, then access the memory
> from that thread.  Then if it did not segfault i know the address was
> valid.
>
> Is there a better way to do this ?

Portably? No.

Unportable? Yes. Use ptrace and PTRACE_PEEK?

Cheers,
Carlos.



More information about the Libc-help mailing list