Determining if an address is valid prior to using it.

Mark Seaborn mrs@mythic-beasts.com
Thu Aug 7 17:53:00 GMT 2008


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 ?

You could use /proc/self/maps to determine whether the address is
contained within a mapped page.  glibc itself uses this in some
obscure cases to determine whether printf format strings are writable.

This might not give the behaviour you want for the stack, because I
think /proc/self/maps reports what has been used rather than what
could be used.

I hesitate to recommend /proc/self/maps because it is hard to
implement in Plash, but that is really my problem rather than your
problem. :-)

Regards
Mark



More information about the Libc-help mailing list