diff options
author | Frank Ch. Eigler <fche@redhat.com> | 2004-09-07 21:52:52 +0000 |
---|---|---|
committer | Frank Ch. Eigler <fche@gcc.gnu.org> | 2004-09-07 21:52:52 +0000 |
commit | 66a5d3b1c1af7dca783626c5c8470c13cdb246e8 (patch) | |
tree | 60266192b1071f716dc829f1db1f87f97112b81a /libmudflap/mf-hooks2.c | |
parent | ec666d23ca0f507e0940bcdf0b65848bceb1af30 (diff) | |
download | gcc-66a5d3b1c1af7dca783626c5c8470c13cdb246e8.zip gcc-66a5d3b1c1af7dca783626c5c8470c13cdb246e8.tar.gz gcc-66a5d3b1c1af7dca783626c5c8470c13cdb246e8.tar.bz2 |
configure.ac: Look for pwd.h, grp.h, netdb.h headers and functions.
2004-09-07 Frank Ch. Eigler <fche@redhat.com>
* configure.ac: Look for pwd.h, grp.h, netdb.h headers and functions.
* mf-hooks2.c (strerror): Unregister previous string returned by
previous strerror.
(getlogin,cuserid,getpwnam,getpwuid,getgrnam,getgrgid): New wrappers.
(getservent,getservbyname,getservbyport,gai_strerror): Ditto.
* mf-runtime.h.in: Add redefine_extname pragmas for them all.
* mf-runtime.c (__mf_describe_object): Clarify object life status.
* testsuite/libmudflap.c/pass48-frag.c, pass49-frag.c, fail32-frag.c:
New tests.
* configure, config.h.in: Regenerated.
From-SVN: r87160
Diffstat (limited to 'libmudflap/mf-hooks2.c')
-rw-r--r-- | libmudflap/mf-hooks2.c | 171 |
1 files changed, 160 insertions, 11 deletions
diff --git a/libmudflap/mf-hooks2.c b/libmudflap/mf-hooks2.c index e031b43..640b78e 100644 --- a/libmudflap/mf-hooks2.c +++ b/libmudflap/mf-hooks2.c @@ -84,7 +84,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #ifdef HAVE_SYS_SHM_H #include <sys/shm.h> #endif - +#ifdef HAVE_PWD_H +#include <pwd.h> +#endif +#ifdef HAVE_GRP_H +#include <grp.h> +#endif #include "mf-runtime.h" #include "mf-impl.h" @@ -524,7 +529,6 @@ WRAPPER2(struct tm*, gmtime, const time_t *timep) /* The following indicate if the result of the corresponding function * should be explicitly un/registered by the wrapper */ -#define MF_REGISTER_strerror __MF_TYPE_STATIC #undef MF_REGISTER_fopen #define MF_RESULT_SIZE_fopen (sizeof (FILE)) #undef MF_REGISTER_opendir @@ -552,17 +556,15 @@ WRAPPER2(time_t, time, time_t *timep) WRAPPER2(char *, strerror, int errnum) { char *p; - size_t n; + static char * last_strerror = NULL; + TRACE ("%s\n", __PRETTY_FUNCTION__); p = strerror (errnum); - if (NULL != p) { - n = strlen (p); - n = CLAMPADD(n, 1); -#ifdef MF_REGISTER_strerror - __mf_register (p, n, MF_REGISTER_strerror, "strerror result"); -#endif - MF_VALIDATE_EXTENT (p, n, __MF_CHECK_WRITE, "strerror result"); - } + if (last_strerror != NULL) + __mf_unregister (last_strerror, 0, __MF_TYPE_STATIC); + if (NULL != p) + __mf_register (p, strlen (p) + 1, __MF_TYPE_STATIC, "strerror result"); + last_strerror = p; return p; } @@ -1722,3 +1724,150 @@ WRAPPER2(int **, __ctype_tolower_loc, void) return ptr; } #endif + + +/* passwd/group related functions. These register every (static) pointer value returned, + and rely on libmudflap's quiet toleration of duplicate static registrations. */ + +#ifdef HAVE_GETLOGIN +WRAPPER2(char *, getlogin, void) +{ + char *buf = getlogin (); + if (buf != NULL) + __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC, + "getlogin() return"); + return buf; +} +#endif + + +#ifdef HAVE_CUSERID +WRAPPER2(char *, cuserid, char * buf) +{ + if (buf != NULL) + { + MF_VALIDATE_EXTENT(buf, L_cuserid, __MF_CHECK_WRITE, + "cuserid destination"); + return cuserid (buf); + } + buf = cuserid (NULL); + if (buf != NULL) + __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC, + "getcuserid() return"); + return buf; +} +#endif + + +#ifdef HAVE_GETPWNAM +WRAPPER2(struct passwd *, getpwnam, const char *name) +{ + struct passwd *buf; + MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ, + "getpwnam name"); + buf = getpwnam (name); + if (buf != NULL) + __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC, + "getpw*() return"); + return buf; +} +#endif + + +#ifdef HAVE_GETPWUID +WRAPPER2(struct passwd *, getpwuid, uid_t uid) +{ + struct passwd *buf; + buf = getpwuid (uid); + if (buf != NULL) + __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC, + "getpw*() return"); + return buf; +} +#endif + + +#ifdef HAVE_GETGRNAM +WRAPPER2(struct group *, getgrnam, const char *name) +{ + struct group *buf; + MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ, + "getgrnam name"); + buf = getgrnam (name); + if (buf != NULL) + __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC, + "getgr*() return"); + return buf; +} +#endif + + +#ifdef HAVE_GETGRGID +WRAPPER2(struct group *, getgrgid, uid_t uid) +{ + struct group *buf; + buf = getgrgid (uid); + if (buf != NULL) + __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC, + "getgr*() return"); + return buf; +} +#endif + + +#ifdef HAVE_GETSERVENT +WRAPPER2(struct servent *, getservent, void) +{ + struct servent *buf; + buf = getservent (); + if (buf != NULL) + __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC, + "getserv*() return"); + return buf; +} +#endif + + +#ifdef HAVE_GETSERVBYNAME +WRAPPER2(struct servent *, getservbyname, const char *name, const char *proto) +{ + struct servent *buf; + MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ, + "getservbyname name"); + MF_VALIDATE_EXTENT(proto, strlen(proto)+1, __MF_CHECK_READ, + "getservbyname proto"); + buf = getservbyname (name, proto); + if (buf != NULL) + __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC, + "getserv*() return"); + return buf; +} +#endif + + +#ifdef HAVE_GETSERVBYPORT +WRAPPER2(struct servent *, getservbyport, int port, const char *proto) +{ + struct servent *buf; + MF_VALIDATE_EXTENT(proto, strlen(proto)+1, __MF_CHECK_READ, + "getservbyport proto"); + buf = getservbyport (port, proto); + if (buf != NULL) + __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC, + "getserv*() return"); + return buf; +} +#endif + + +#ifdef HAVE_GAI_STRERROR +WRAPPER2(const char *, gai_strerror, int errcode) +{ + const char *buf; + buf = gai_strerror (errcode); + if (buf != NULL) + __mf_register ((void *) buf, strlen(buf)+1, __MF_TYPE_STATIC, + "gai_strerror() return"); + return buf; +} +#endif |