Mail Archives: djgpp/1999/08/30/19:38:29
In message <Pine DOT SUN DOT 3 DOT 91 DOT 990830094206 DOT 3558B-100000 AT is>, Eli Zaretskii
<eliz AT is DOT elta DOT co DOT il> writes
>> I don't know whether it is possible to right a function which
>> tests for an invalid pointer without bombing.
>
>How about this (UNTESTED)?
>
> void validate_or_die (void *ptr)
> {
> if ( (unsigned)p < 0x1000)
> abort ();
> }
Sounds possible... I'd prefer to log or report rather than abort,
and is there an upper limit?? Also to have it as a test you could put,
at least at infrequently used gateways. Also to report IP
and pointer variable used, which helps if it's in some static or auto
variable [though is less help in some dynamically allocated item].
const void *LO_LIMIT=0x1000
void *HI_LIMIT=0; //assign value
int verify(void **PtrLoc){ void *Ptr=(*PtrLoc), *Rtn=NULL;
asm(
'mov (%ebp+4),%eax\r', 'mov %eax,(Rtn)\r' //syntax?????
: : %eax : //?????
);
if( LO_LIMIT <= (unsigned)Ptr && (unsigned)Ptr < HI_LIMIT){
;
return 1;
};
printf("Instr@%x used Pointer @%x contains %x",Rtn,PtrLoc,Loc);
printf(" outside range %x to %x\n", LO_LIMIT, HI_LIMIT);
; return 0;
};
Assuming of course that RhinoHIDE can turn a numerical code address
back to a function name, and data address back to a variable name.
--
^-^-^-@@-^-;-^ http://www.xemu.demon.co.uk/
(..)__u news:alt.smoking.mooses
- Raw text -