delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/19/06:49:24

From: "Charles Sandmann" <sandmann AT clio DOT rice DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Possible misbehavior of write
Date: Wed, 18 Jun 1997 22:39:11
Organization: Aspen Technology, Inc.
Lines: 22
Message-ID: <33a8638f.sandmann@clio.rice.edu>
References: <199706181248 DOT IAA04330 AT delorie DOT com>
Reply-To: sandmann AT clio DOT rice DOT edu
NNTP-Posting-Host: dcloan.dmccorp.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> POSIX is pretty vague about EFAULT because, as it claims, "not all
> systems can reliably detect it."

We could do several things to improve our detection:

1) provide a function to check pointers to be in the valid address range.  
   This would have to check the limits of each allocated memory zone.  
   This would prevent nearptr hacks outside the normal address space
   or other unusual things from being valid.  The pointer plus length
   should also be checked - but if it's null terminated this can't be
   done with this method.  If the length was huge this method also might
   fail if the start and end spanned non-contiguous memory zones.  This
   method would catch some access to memory spanned by non-contig memory
   zone which will not generate a fault normally.
2) establish a signal handler when entering the function to longjmp back
   to an exit point and set the fault code.  This will catch all the
   bad adresses which would cause a fault (but not necessarily illegally
   addressed spanned memory), but may leave the funtion in a half-done 
   state.  This could probably be done as a nice function setup fairly
   easily.

So - is it worth it?

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019