This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Determining if an address is valid prior to using it.
- From: Mark Seaborn <mrs at mythic-beasts dot com>
- To: libc-help at sourceware dot org
- Date: Thu, 07 Aug 2008 18:46:14 +0100 (BST)
- Subject: Re: Determining if an address is valid prior to using it.
- References: <46835D054D115449BBE84934E2F2000901E54827@ARLEXCHVS02.lst.link.l-3com.com>
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