* mudflap - wrapper question
@ 2003-04-25 17:16 Eyal Lebedinsky
0 siblings, 0 replies; only message in thread
From: Eyal Lebedinsky @ 2003-04-25 17:16 UTC (permalink / raw)
To: list, gcc, Eigler, Frank Ch.
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/>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-04-25 15:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-25 17:16 mudflap - wrapper question Eyal Lebedinsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).