On Friday, February 14, 2003, at 02:11 PM, Brent Marykuca wrote: Hello, Given a pointer value, is there some relatively trivial way to determine whether or not it points to a valid readable or writeable address? i.e. is there a way to find out whether accessing the address will cause a panic? I think you are asking a question that everyone who has ever used the C language would like to have a simple solution to. The answer is no, there is nothing inherent in the language that does this. You can, of course, manage your pointers and make sure you do proper initialization to minimize the chance for violating segment boundaries, etc. (e.g. init to NULL and check if ptr == NULL before using...simple basic stuff). If you feel ambitious, you could always instrument the C RTL and gcc to do range checking and memory management for you. There are debugging tools (Purify, Insure++) that do these types of things. As far as getting a pointer passed to you from external entity: you just have to hope that the interface is being followed (i.e. someone doesn't pass you an un-init'd pointer when you expect a ptr that is init'd, for example. I'm interested in how to do this from a KEXT, but it also seems like it would be a useful ability to have in user-space too. Thanks, Brent Marykuca _______________________________________________ darwin-kernel mailing list | darwin-kernel@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-kernel Do not post admin requests to the list. They will be ignored.
participants (1)
-
Jeff Jenkins