mudflap - wrapper question
Eyal Lebedinsky
eyal@eyal.emu.id.au
Fri Apr 25 17:16:00 GMT 2003
Moving on with the wrappers, and thinking a bit more about
how to deal with objects created outside the instrumented
environment, I now think that this should be safe to do:
#undef MF_REGISTER_OPENDIR
#ifdef WRAP_opendir
#include <dirent.h>
WRAPPER2(DIR *, opendir, const char *path)
{
DIR *p;
size_t n = strlen (path);
MF_VALIDATE_EXTENT(path, CLAMPADD(n, 1), __MF_CHECK_READ, "opendir
path");
p = opendir (path);
if (NULL != p) {
#ifdef MF_REGISTER_OPENDIR
__mf_register (p, 0, __MF_TYPE_STATIC, "opendir result");
#endif
MF_VALIDATE_EXTENT(p, 0, __MF_CHECK_WRITE, "opendir result");
}
return p;
}
#endif
#ifdef WRAP_closedir
#include <dirent.h>
WRAPPER2(int, closedir, DIR *dir)
{
MF_VALIDATE_EXTENT(dir, 0, __MF_CHECK_WRITE, "closedir dir");
#ifdef MF_REGISTER_OPENDIR
__mf_unregister (dir, 0);
#endif
return closedir (dir);
}
#endif
The point of the MF_VALIDATE_EXTENT at the end of opendir()_ is
to mark the memory as written to. While the malloc may have been
trapped, the fact that it was written to was not established.
Is this correct to do?
--
Eyal Lebedinsky (eyal@eyal.emu.id.au) <http://samba.org/eyal/>
More information about the Gcc
mailing list