OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libmudflap/] [mf-hooks2.c] - Diff between revs 154 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 154 Rev 816
/* Mudflap: narrow-pointer bounds-checking by tree rewriting.
/* Mudflap: narrow-pointer bounds-checking by tree rewriting.
   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
   Contributed by Frank Ch. Eigler <fche@redhat.com>
   Contributed by Frank Ch. Eigler <fche@redhat.com>
   and Graydon Hoare <graydon@redhat.com>
   and Graydon Hoare <graydon@redhat.com>
 
 
This file is part of GCC.
This file is part of GCC.
 
 
GCC is free software; you can redistribute it and/or modify it under
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
version.
 
 
In addition to the permissions in the GNU General Public License, the
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
and to distribute those combinations without any restriction coming
from the use of this file.  (The General Public License restrictions
from the use of this file.  (The General Public License restrictions
do apply in other respects; for example, they cover modification of
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
the file, and distribution when not linked into a combine
executable.)
executable.)
 
 
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.
for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING.  If not, write to the Free
along with GCC; see the file COPYING.  If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.  */
02110-1301, USA.  */
 
 
 
 
#include "config.h"
#include "config.h"
 
 
#ifndef HAVE_SOCKLEN_T
#ifndef HAVE_SOCKLEN_T
#define socklen_t int
#define socklen_t int
#endif
#endif
 
 
/* These attempt to coax various unix flavours to declare all our
/* These attempt to coax various unix flavours to declare all our
   needed tidbits in the system headers.  */
   needed tidbits in the system headers.  */
#if !defined(__FreeBSD__) && !defined(__APPLE__)
#if !defined(__FreeBSD__) && !defined(__APPLE__)
#define _POSIX_SOURCE
#define _POSIX_SOURCE
#endif /* Some BSDs break <sys/socket.h> if this is defined. */
#endif /* Some BSDs break <sys/socket.h> if this is defined. */
#define _GNU_SOURCE
#define _GNU_SOURCE
#define _XOPEN_SOURCE
#define _XOPEN_SOURCE
#define _BSD_TYPES
#define _BSD_TYPES
#define __EXTENSIONS__
#define __EXTENSIONS__
#define _ALL_SOURCE
#define _ALL_SOURCE
#define _LARGE_FILE_API
#define _LARGE_FILE_API
#define _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#define _XOPEN_SOURCE_EXTENDED 1
#define _XOPEN_SOURCE_EXTENDED 1
 
 
#include <string.h>
#include <string.h>
#include <stdarg.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/types.h>
#include <unistd.h>
#include <unistd.h>
#include <assert.h>
#include <assert.h>
#include <errno.h>
#include <errno.h>
#include <limits.h>
#include <limits.h>
#include <time.h>
#include <time.h>
#include <ctype.h>
#include <ctype.h>
#ifdef HAVE_DLFCN_H
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#include <dlfcn.h>
#endif
#endif
#ifdef HAVE_DIRENT_H
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#include <dirent.h>
#endif
#endif
#ifdef HAVE_SYS_SOCKET_H
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#include <sys/socket.h>
#endif
#endif
#ifdef HAVE_NETDB_H
#ifdef HAVE_NETDB_H
#include <netdb.h>
#include <netdb.h>
#endif
#endif
#ifdef HAVE_SYS_WAIT_H
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#include <sys/wait.h>
#endif
#endif
#ifdef HAVE_SYS_IPC_H
#ifdef HAVE_SYS_IPC_H
#include <sys/ipc.h>
#include <sys/ipc.h>
#endif
#endif
#ifdef HAVE_SYS_SEM_H
#ifdef HAVE_SYS_SEM_H
#include <sys/sem.h>
#include <sys/sem.h>
#endif
#endif
#ifdef HAVE_SYS_SHM_H
#ifdef HAVE_SYS_SHM_H
#include <sys/shm.h>
#include <sys/shm.h>
#endif
#endif
#ifdef HAVE_PWD_H
#ifdef HAVE_PWD_H
#include <pwd.h>
#include <pwd.h>
#endif
#endif
#ifdef HAVE_GRP_H
#ifdef HAVE_GRP_H
#include <grp.h>
#include <grp.h>
#endif
#endif
#ifdef HAVE_MNTENT_H
#ifdef HAVE_MNTENT_H
#include <mntent.h>
#include <mntent.h>
#endif
#endif
#ifdef HAVE_SYS_SOCKET_H
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#include <sys/socket.h>
#endif
#endif
#ifdef HAVE_NETINET_IN_H
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#include <netinet/in.h>
#endif
#endif
#ifdef HAVE_ARPA_INET_H
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#include <arpa/inet.h>
#endif
#endif
 
 
#include "mf-runtime.h"
#include "mf-runtime.h"
#include "mf-impl.h"
#include "mf-impl.h"
 
 
#ifdef _MUDFLAP
#ifdef _MUDFLAP
#error "Do not compile this file with -fmudflap!"
#error "Do not compile this file with -fmudflap!"
#endif
#endif
 
 
 
 
/* A bunch of independent stdlib/unistd hook functions, all
/* A bunch of independent stdlib/unistd hook functions, all
   intercepted by mf-runtime.h macros.  */
   intercepted by mf-runtime.h macros.  */
 
 
#ifndef HAVE_STRNLEN
#ifndef HAVE_STRNLEN
static inline size_t (strnlen) (const char* str, size_t n)
static inline size_t (strnlen) (const char* str, size_t n)
{
{
  const char *s;
  const char *s;
 
 
  for (s = str; n && *s; ++s, --n)
  for (s = str; n && *s; ++s, --n)
    ;
    ;
  return (s - str);
  return (s - str);
}
}
#endif
#endif
 
 
 
 
/* str*,mem*,b* */
/* str*,mem*,b* */
 
 
WRAPPER2(void *, memcpy, void *dest, const void *src, size_t n)
WRAPPER2(void *, memcpy, void *dest, const void *src, size_t n)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "memcpy source");
  MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "memcpy source");
  MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "memcpy dest");
  MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "memcpy dest");
  return memcpy (dest, src, n);
  return memcpy (dest, src, n);
}
}
 
 
 
 
WRAPPER2(void *, memmove, void *dest, const void *src, size_t n)
WRAPPER2(void *, memmove, void *dest, const void *src, size_t n)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "memmove src");
  MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "memmove src");
  MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "memmove dest");
  MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "memmove dest");
  return memmove (dest, src, n);
  return memmove (dest, src, n);
}
}
 
 
 
 
WRAPPER2(void *, memset, void *s, int c, size_t n)
WRAPPER2(void *, memset, void *s, int c, size_t n)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "memset dest");
  MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "memset dest");
  return memset (s, c, n);
  return memset (s, c, n);
}
}
 
 
 
 
WRAPPER2(int, memcmp, const void *s1, const void *s2, size_t n)
WRAPPER2(int, memcmp, const void *s1, const void *s2, size_t n)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "memcmp 1st arg");
  MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "memcmp 1st arg");
  MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "memcmp 2nd arg");
  MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "memcmp 2nd arg");
  return memcmp (s1, s2, n);
  return memcmp (s1, s2, n);
}
}
 
 
 
 
WRAPPER2(void *, memchr, const void *s, int c, size_t n)
WRAPPER2(void *, memchr, const void *s, int c, size_t n)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(s, n, __MF_CHECK_READ, "memchr region");
  MF_VALIDATE_EXTENT(s, n, __MF_CHECK_READ, "memchr region");
  return memchr (s, c, n);
  return memchr (s, c, n);
}
}
 
 
 
 
#ifdef HAVE_MEMRCHR
#ifdef HAVE_MEMRCHR
WRAPPER2(void *, memrchr, const void *s, int c, size_t n)
WRAPPER2(void *, memrchr, const void *s, int c, size_t n)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(s, n, __MF_CHECK_READ, "memrchr region");
  MF_VALIDATE_EXTENT(s, n, __MF_CHECK_READ, "memrchr region");
  return memrchr (s, c, n);
  return memrchr (s, c, n);
}
}
#endif
#endif
 
 
 
 
WRAPPER2(char *, strcpy, char *dest, const char *src)
WRAPPER2(char *, strcpy, char *dest, const char *src)
{
{
  /* nb: just because strlen(src) == n doesn't mean (src + n) or (src + n +
  /* nb: just because strlen(src) == n doesn't mean (src + n) or (src + n +
     1) are valid pointers. the allocated object might have size < n.
     1) are valid pointers. the allocated object might have size < n.
     check anyways. */
     check anyways. */
 
 
  size_t n = strlen (src);
  size_t n = strlen (src);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(src, CLAMPADD(n, 1), __MF_CHECK_READ, "strcpy src");
  MF_VALIDATE_EXTENT(src, CLAMPADD(n, 1), __MF_CHECK_READ, "strcpy src");
  MF_VALIDATE_EXTENT(dest, CLAMPADD(n, 1), __MF_CHECK_WRITE, "strcpy dest");
  MF_VALIDATE_EXTENT(dest, CLAMPADD(n, 1), __MF_CHECK_WRITE, "strcpy dest");
  return strcpy (dest, src);
  return strcpy (dest, src);
}
}
 
 
 
 
#ifdef HAVE_STRNCPY
#ifdef HAVE_STRNCPY
WRAPPER2(char *, strncpy, char *dest, const char *src, size_t n)
WRAPPER2(char *, strncpy, char *dest, const char *src, size_t n)
{
{
  size_t len = strnlen (src, n);
  size_t len = strnlen (src, n);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(src, len, __MF_CHECK_READ, "strncpy src");
  MF_VALIDATE_EXTENT(src, len, __MF_CHECK_READ, "strncpy src");
  MF_VALIDATE_EXTENT(dest, len, __MF_CHECK_WRITE, "strncpy dest"); /* nb: strNcpy */
  MF_VALIDATE_EXTENT(dest, len, __MF_CHECK_WRITE, "strncpy dest"); /* nb: strNcpy */
  return strncpy (dest, src, n);
  return strncpy (dest, src, n);
}
}
#endif
#endif
 
 
 
 
WRAPPER2(char *, strcat, char *dest, const char *src)
WRAPPER2(char *, strcat, char *dest, const char *src)
{
{
  size_t dest_sz;
  size_t dest_sz;
  size_t src_sz;
  size_t src_sz;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  dest_sz = strlen (dest);
  dest_sz = strlen (dest);
  src_sz = strlen (src);
  src_sz = strlen (src);
  MF_VALIDATE_EXTENT(src, CLAMPADD(src_sz, 1), __MF_CHECK_READ, "strcat src");
  MF_VALIDATE_EXTENT(src, CLAMPADD(src_sz, 1), __MF_CHECK_READ, "strcat src");
  MF_VALIDATE_EXTENT(dest, CLAMPADD(dest_sz, CLAMPADD(src_sz, 1)),
  MF_VALIDATE_EXTENT(dest, CLAMPADD(dest_sz, CLAMPADD(src_sz, 1)),
                     __MF_CHECK_WRITE, "strcat dest");
                     __MF_CHECK_WRITE, "strcat dest");
  return strcat (dest, src);
  return strcat (dest, src);
}
}
 
 
 
 
WRAPPER2(char *, strncat, char *dest, const char *src, size_t n)
WRAPPER2(char *, strncat, char *dest, const char *src, size_t n)
{
{
 
 
  /* nb: validating the extents (s,n) might be a mistake for two reasons.
  /* nb: validating the extents (s,n) might be a mistake for two reasons.
 
 
  (1) the string s might be shorter than n chars, and n is just a
  (1) the string s might be shorter than n chars, and n is just a
  poor choice by the programmer. this is not a "true" error in the
  poor choice by the programmer. this is not a "true" error in the
  sense that the call to strncat would still be ok.
  sense that the call to strncat would still be ok.
 
 
  (2) we could try to compensate for case (1) by calling strlen(s) and
  (2) we could try to compensate for case (1) by calling strlen(s) and
  using that as a bound for the extent to verify, but strlen might fall off
  using that as a bound for the extent to verify, but strlen might fall off
  the end of a non-terminated string, leading to a false positive.
  the end of a non-terminated string, leading to a false positive.
 
 
  so we will call strnlen(s,n) and use that as a bound.
  so we will call strnlen(s,n) and use that as a bound.
 
 
  if strnlen returns a length beyond the end of the registered extent
  if strnlen returns a length beyond the end of the registered extent
  associated with s, there is an error: the programmer's estimate for n is
  associated with s, there is an error: the programmer's estimate for n is
  too large _AND_ the string s is unterminated, in which case they'd be
  too large _AND_ the string s is unterminated, in which case they'd be
  about to touch memory they don't own while calling strncat.
  about to touch memory they don't own while calling strncat.
 
 
  this same logic applies to further uses of strnlen later down in this
  this same logic applies to further uses of strnlen later down in this
  file. */
  file. */
 
 
  size_t src_sz;
  size_t src_sz;
  size_t dest_sz;
  size_t dest_sz;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  src_sz = strnlen (src, n);
  src_sz = strnlen (src, n);
  dest_sz = strnlen (dest, n);
  dest_sz = strnlen (dest, n);
  MF_VALIDATE_EXTENT(src, src_sz, __MF_CHECK_READ, "strncat src");
  MF_VALIDATE_EXTENT(src, src_sz, __MF_CHECK_READ, "strncat src");
  MF_VALIDATE_EXTENT(dest, (CLAMPADD(dest_sz, CLAMPADD(src_sz, 1))),
  MF_VALIDATE_EXTENT(dest, (CLAMPADD(dest_sz, CLAMPADD(src_sz, 1))),
                     __MF_CHECK_WRITE, "strncat dest");
                     __MF_CHECK_WRITE, "strncat dest");
  return strncat (dest, src, n);
  return strncat (dest, src, n);
}
}
 
 
 
 
WRAPPER2(int, strcmp, const char *s1, const char *s2)
WRAPPER2(int, strcmp, const char *s1, const char *s2)
{
{
  size_t s1_sz;
  size_t s1_sz;
  size_t s2_sz;
  size_t s2_sz;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  s1_sz = strlen (s1);
  s1_sz = strlen (s1);
  s2_sz = strlen (s2);
  s2_sz = strlen (s2);
  MF_VALIDATE_EXTENT(s1, CLAMPADD(s1_sz, 1), __MF_CHECK_READ, "strcmp 1st arg");
  MF_VALIDATE_EXTENT(s1, CLAMPADD(s1_sz, 1), __MF_CHECK_READ, "strcmp 1st arg");
  MF_VALIDATE_EXTENT(s2, CLAMPADD(s2_sz, 1), __MF_CHECK_WRITE, "strcmp 2nd arg");
  MF_VALIDATE_EXTENT(s2, CLAMPADD(s2_sz, 1), __MF_CHECK_WRITE, "strcmp 2nd arg");
  return strcmp (s1, s2);
  return strcmp (s1, s2);
}
}
 
 
 
 
WRAPPER2(int, strcasecmp, const char *s1, const char *s2)
WRAPPER2(int, strcasecmp, const char *s1, const char *s2)
{
{
  size_t s1_sz;
  size_t s1_sz;
  size_t s2_sz;
  size_t s2_sz;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  s1_sz = strlen (s1);
  s1_sz = strlen (s1);
  s2_sz = strlen (s2);
  s2_sz = strlen (s2);
  MF_VALIDATE_EXTENT(s1, CLAMPADD(s1_sz, 1), __MF_CHECK_READ, "strcasecmp 1st arg");
  MF_VALIDATE_EXTENT(s1, CLAMPADD(s1_sz, 1), __MF_CHECK_READ, "strcasecmp 1st arg");
  MF_VALIDATE_EXTENT(s2, CLAMPADD(s2_sz, 1), __MF_CHECK_READ, "strcasecmp 2nd arg");
  MF_VALIDATE_EXTENT(s2, CLAMPADD(s2_sz, 1), __MF_CHECK_READ, "strcasecmp 2nd arg");
  return strcasecmp (s1, s2);
  return strcasecmp (s1, s2);
}
}
 
 
 
 
WRAPPER2(int, strncmp, const char *s1, const char *s2, size_t n)
WRAPPER2(int, strncmp, const char *s1, const char *s2, size_t n)
{
{
  size_t s1_sz;
  size_t s1_sz;
  size_t s2_sz;
  size_t s2_sz;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  s1_sz = strnlen (s1, n);
  s1_sz = strnlen (s1, n);
  s2_sz = strnlen (s2, n);
  s2_sz = strnlen (s2, n);
  MF_VALIDATE_EXTENT(s1, s1_sz, __MF_CHECK_READ, "strncmp 1st arg");
  MF_VALIDATE_EXTENT(s1, s1_sz, __MF_CHECK_READ, "strncmp 1st arg");
  MF_VALIDATE_EXTENT(s2, s2_sz, __MF_CHECK_READ, "strncmp 2nd arg");
  MF_VALIDATE_EXTENT(s2, s2_sz, __MF_CHECK_READ, "strncmp 2nd arg");
  return strncmp (s1, s2, n);
  return strncmp (s1, s2, n);
}
}
 
 
 
 
WRAPPER2(int, strncasecmp, const char *s1, const char *s2, size_t n)
WRAPPER2(int, strncasecmp, const char *s1, const char *s2, size_t n)
{
{
  size_t s1_sz;
  size_t s1_sz;
  size_t s2_sz;
  size_t s2_sz;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  s1_sz = strnlen (s1, n);
  s1_sz = strnlen (s1, n);
  s2_sz = strnlen (s2, n);
  s2_sz = strnlen (s2, n);
  MF_VALIDATE_EXTENT(s1, s1_sz, __MF_CHECK_READ, "strncasecmp 1st arg");
  MF_VALIDATE_EXTENT(s1, s1_sz, __MF_CHECK_READ, "strncasecmp 1st arg");
  MF_VALIDATE_EXTENT(s2, s2_sz, __MF_CHECK_READ, "strncasecmp 2nd arg");
  MF_VALIDATE_EXTENT(s2, s2_sz, __MF_CHECK_READ, "strncasecmp 2nd arg");
  return strncasecmp (s1, s2, n);
  return strncasecmp (s1, s2, n);
}
}
 
 
 
 
WRAPPER2(char *, strdup, const char *s)
WRAPPER2(char *, strdup, const char *s)
{
{
  DECLARE(void *, malloc, size_t sz);
  DECLARE(void *, malloc, size_t sz);
  char *result;
  char *result;
  size_t n = strlen (s);
  size_t n = strlen (s);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(s, CLAMPADD(n,1), __MF_CHECK_READ, "strdup region");
  MF_VALIDATE_EXTENT(s, CLAMPADD(n,1), __MF_CHECK_READ, "strdup region");
  result = (char *)CALL_REAL(malloc,
  result = (char *)CALL_REAL(malloc,
                             CLAMPADD(CLAMPADD(n,1),
                             CLAMPADD(CLAMPADD(n,1),
                                      CLAMPADD(__mf_opts.crumple_zone,
                                      CLAMPADD(__mf_opts.crumple_zone,
                                               __mf_opts.crumple_zone)));
                                               __mf_opts.crumple_zone)));
 
 
  if (UNLIKELY(! result)) return result;
  if (UNLIKELY(! result)) return result;
 
 
  result += __mf_opts.crumple_zone;
  result += __mf_opts.crumple_zone;
  memcpy (result, s, n);
  memcpy (result, s, n);
  result[n] = '\0';
  result[n] = '\0';
 
 
  __mf_register (result, CLAMPADD(n,1), __MF_TYPE_HEAP_I, "strdup region");
  __mf_register (result, CLAMPADD(n,1), __MF_TYPE_HEAP_I, "strdup region");
  return result;
  return result;
}
}
 
 
 
 
WRAPPER2(char *, strndup, const char *s, size_t n)
WRAPPER2(char *, strndup, const char *s, size_t n)
{
{
  DECLARE(void *, malloc, size_t sz);
  DECLARE(void *, malloc, size_t sz);
  char *result;
  char *result;
  size_t sz = strnlen (s, n);
  size_t sz = strnlen (s, n);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(s, sz, __MF_CHECK_READ, "strndup region"); /* nb: strNdup */
  MF_VALIDATE_EXTENT(s, sz, __MF_CHECK_READ, "strndup region"); /* nb: strNdup */
 
 
  /* note: strndup still adds a \0, even with the N limit! */
  /* note: strndup still adds a \0, even with the N limit! */
  result = (char *)CALL_REAL(malloc,
  result = (char *)CALL_REAL(malloc,
                             CLAMPADD(CLAMPADD(n,1),
                             CLAMPADD(CLAMPADD(n,1),
                                      CLAMPADD(__mf_opts.crumple_zone,
                                      CLAMPADD(__mf_opts.crumple_zone,
                                               __mf_opts.crumple_zone)));
                                               __mf_opts.crumple_zone)));
 
 
  if (UNLIKELY(! result)) return result;
  if (UNLIKELY(! result)) return result;
 
 
  result += __mf_opts.crumple_zone;
  result += __mf_opts.crumple_zone;
  memcpy (result, s, n);
  memcpy (result, s, n);
  result[n] = '\0';
  result[n] = '\0';
 
 
  __mf_register (result, CLAMPADD(n,1), __MF_TYPE_HEAP_I, "strndup region");
  __mf_register (result, CLAMPADD(n,1), __MF_TYPE_HEAP_I, "strndup region");
  return result;
  return result;
}
}
 
 
 
 
WRAPPER2(char *, strchr, const char *s, int c)
WRAPPER2(char *, strchr, const char *s, int c)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (s);
  n = strlen (s);
  MF_VALIDATE_EXTENT(s, CLAMPADD(n,1), __MF_CHECK_READ, "strchr region");
  MF_VALIDATE_EXTENT(s, CLAMPADD(n,1), __MF_CHECK_READ, "strchr region");
  return strchr (s, c);
  return strchr (s, c);
}
}
 
 
 
 
WRAPPER2(char *, strrchr, const char *s, int c)
WRAPPER2(char *, strrchr, const char *s, int c)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (s);
  n = strlen (s);
  MF_VALIDATE_EXTENT(s, CLAMPADD(n,1), __MF_CHECK_READ, "strrchr region");
  MF_VALIDATE_EXTENT(s, CLAMPADD(n,1), __MF_CHECK_READ, "strrchr region");
  return strrchr (s, c);
  return strrchr (s, c);
}
}
 
 
 
 
WRAPPER2(char *, strstr, const char *haystack, const char *needle)
WRAPPER2(char *, strstr, const char *haystack, const char *needle)
{
{
  size_t haystack_sz;
  size_t haystack_sz;
  size_t needle_sz;
  size_t needle_sz;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  haystack_sz = strlen (haystack);
  haystack_sz = strlen (haystack);
  needle_sz = strlen (needle);
  needle_sz = strlen (needle);
  MF_VALIDATE_EXTENT(haystack, CLAMPADD(haystack_sz, 1), __MF_CHECK_READ, "strstr haystack");
  MF_VALIDATE_EXTENT(haystack, CLAMPADD(haystack_sz, 1), __MF_CHECK_READ, "strstr haystack");
  MF_VALIDATE_EXTENT(needle, CLAMPADD(needle_sz, 1), __MF_CHECK_READ, "strstr needle");
  MF_VALIDATE_EXTENT(needle, CLAMPADD(needle_sz, 1), __MF_CHECK_READ, "strstr needle");
  return strstr (haystack, needle);
  return strstr (haystack, needle);
}
}
 
 
 
 
#ifdef HAVE_MEMMEM
#ifdef HAVE_MEMMEM
WRAPPER2(void *, memmem,
WRAPPER2(void *, memmem,
        const void *haystack, size_t haystacklen,
        const void *haystack, size_t haystacklen,
        const void *needle, size_t needlelen)
        const void *needle, size_t needlelen)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(haystack, haystacklen, __MF_CHECK_READ, "memmem haystack");
  MF_VALIDATE_EXTENT(haystack, haystacklen, __MF_CHECK_READ, "memmem haystack");
  MF_VALIDATE_EXTENT(needle, needlelen, __MF_CHECK_READ, "memmem needle");
  MF_VALIDATE_EXTENT(needle, needlelen, __MF_CHECK_READ, "memmem needle");
  return memmem (haystack, haystacklen, needle, needlelen);
  return memmem (haystack, haystacklen, needle, needlelen);
}
}
#endif
#endif
 
 
 
 
WRAPPER2(size_t, strlen, const char *s)
WRAPPER2(size_t, strlen, const char *s)
{
{
  size_t result = strlen (s);
  size_t result = strlen (s);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(s, CLAMPADD(result, 1), __MF_CHECK_READ, "strlen region");
  MF_VALIDATE_EXTENT(s, CLAMPADD(result, 1), __MF_CHECK_READ, "strlen region");
  return result;
  return result;
}
}
 
 
 
 
WRAPPER2(size_t, strnlen, const char *s, size_t n)
WRAPPER2(size_t, strnlen, const char *s, size_t n)
{
{
  size_t result = strnlen (s, n);
  size_t result = strnlen (s, n);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(s, result, __MF_CHECK_READ, "strnlen region");
  MF_VALIDATE_EXTENT(s, result, __MF_CHECK_READ, "strnlen region");
  return result;
  return result;
}
}
 
 
 
 
WRAPPER2(void, bzero, void *s, size_t n)
WRAPPER2(void, bzero, void *s, size_t n)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "bzero region");
  MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "bzero region");
  bzero (s, n);
  bzero (s, n);
}
}
 
 
 
 
#undef bcopy
#undef bcopy
WRAPPER2(void, bcopy, const void *src, void *dest, size_t n)
WRAPPER2(void, bcopy, const void *src, void *dest, size_t n)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "bcopy src");
  MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "bcopy src");
  MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "bcopy dest");
  MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "bcopy dest");
  bcopy (src, dest, n);
  bcopy (src, dest, n);
}
}
 
 
 
 
#undef bcmp
#undef bcmp
WRAPPER2(int, bcmp, const void *s1, const void *s2, size_t n)
WRAPPER2(int, bcmp, const void *s1, const void *s2, size_t n)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "bcmp 1st arg");
  MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "bcmp 1st arg");
  MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "bcmp 2nd arg");
  MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "bcmp 2nd arg");
  return bcmp (s1, s2, n);
  return bcmp (s1, s2, n);
}
}
 
 
 
 
WRAPPER2(char *, index, const char *s, int c)
WRAPPER2(char *, index, const char *s, int c)
{
{
  size_t n = strlen (s);
  size_t n = strlen (s);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "index region");
  MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "index region");
  return index (s, c);
  return index (s, c);
}
}
 
 
 
 
WRAPPER2(char *, rindex, const char *s, int c)
WRAPPER2(char *, rindex, const char *s, int c)
{
{
  size_t n = strlen (s);
  size_t n = strlen (s);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "rindex region");
  MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "rindex region");
  return rindex (s, c);
  return rindex (s, c);
}
}
 
 
/* XXX:  stpcpy, memccpy */
/* XXX:  stpcpy, memccpy */
 
 
/* XXX: *printf,*scanf */
/* XXX: *printf,*scanf */
 
 
/* XXX: setjmp, longjmp */
/* XXX: setjmp, longjmp */
 
 
WRAPPER2(char *, asctime, struct tm *tm)
WRAPPER2(char *, asctime, struct tm *tm)
{
{
  static char *reg_result = NULL;
  static char *reg_result = NULL;
  char *result;
  char *result;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(tm, sizeof (struct tm), __MF_CHECK_READ, "asctime tm");
  MF_VALIDATE_EXTENT(tm, sizeof (struct tm), __MF_CHECK_READ, "asctime tm");
  result = asctime (tm);
  result = asctime (tm);
  if (reg_result == NULL)
  if (reg_result == NULL)
    {
    {
      __mf_register (result, strlen (result)+1, __MF_TYPE_STATIC, "asctime string");
      __mf_register (result, strlen (result)+1, __MF_TYPE_STATIC, "asctime string");
      reg_result = result;
      reg_result = result;
    }
    }
  return result;
  return result;
}
}
 
 
 
 
WRAPPER2(char *, ctime, const time_t *timep)
WRAPPER2(char *, ctime, const time_t *timep)
{
{
  static char *reg_result = NULL;
  static char *reg_result = NULL;
  char *result;
  char *result;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(timep, sizeof (time_t), __MF_CHECK_READ, "ctime time");
  MF_VALIDATE_EXTENT(timep, sizeof (time_t), __MF_CHECK_READ, "ctime time");
  result = ctime (timep);
  result = ctime (timep);
  if (reg_result == NULL)
  if (reg_result == NULL)
    {
    {
      /* XXX: what if asctime and ctime return the same static ptr? */
      /* XXX: what if asctime and ctime return the same static ptr? */
      __mf_register (result, strlen (result)+1, __MF_TYPE_STATIC, "ctime string");
      __mf_register (result, strlen (result)+1, __MF_TYPE_STATIC, "ctime string");
      reg_result = result;
      reg_result = result;
    }
    }
  return result;
  return result;
}
}
 
 
 
 
WRAPPER2(struct tm*, localtime, const time_t *timep)
WRAPPER2(struct tm*, localtime, const time_t *timep)
{
{
  static struct tm *reg_result = NULL;
  static struct tm *reg_result = NULL;
  struct tm *result;
  struct tm *result;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(timep, sizeof (time_t), __MF_CHECK_READ, "localtime time");
  MF_VALIDATE_EXTENT(timep, sizeof (time_t), __MF_CHECK_READ, "localtime time");
  result = localtime (timep);
  result = localtime (timep);
  if (reg_result == NULL)
  if (reg_result == NULL)
    {
    {
      __mf_register (result, sizeof (struct tm), __MF_TYPE_STATIC, "localtime tm");
      __mf_register (result, sizeof (struct tm), __MF_TYPE_STATIC, "localtime tm");
      reg_result = result;
      reg_result = result;
    }
    }
  return result;
  return result;
}
}
 
 
 
 
WRAPPER2(struct tm*, gmtime, const time_t *timep)
WRAPPER2(struct tm*, gmtime, const time_t *timep)
{
{
  static struct tm *reg_result = NULL;
  static struct tm *reg_result = NULL;
  struct tm *result;
  struct tm *result;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT(timep, sizeof (time_t), __MF_CHECK_READ, "gmtime time");
  MF_VALIDATE_EXTENT(timep, sizeof (time_t), __MF_CHECK_READ, "gmtime time");
  result = gmtime (timep);
  result = gmtime (timep);
  if (reg_result == NULL)
  if (reg_result == NULL)
    {
    {
      __mf_register (result, sizeof (struct tm), __MF_TYPE_STATIC, "gmtime tm");
      __mf_register (result, sizeof (struct tm), __MF_TYPE_STATIC, "gmtime tm");
      reg_result = result;
      reg_result = result;
    }
    }
  return result;
  return result;
}
}
 
 
 
 
/* EL start */
/* EL start */
 
 
/* The following indicate if the result of the corresponding function
/* The following indicate if the result of the corresponding function
 * should be explicitly un/registered by the wrapper
 * should be explicitly un/registered by the wrapper
*/
*/
 
 
#ifdef __FreeBSD__
#ifdef __FreeBSD__
#define MF_REGISTER_fopen               __MF_TYPE_STATIC
#define MF_REGISTER_fopen               __MF_TYPE_STATIC
#else
#else
#undef  MF_REGISTER_fopen
#undef  MF_REGISTER_fopen
#endif
#endif
#define MF_RESULT_SIZE_fopen            (sizeof (FILE))
#define MF_RESULT_SIZE_fopen            (sizeof (FILE))
 
 
#undef  MF_REGISTER_opendir
#undef  MF_REGISTER_opendir
#define MF_RESULT_SIZE_opendir          0        /* (sizeof (DIR)) */
#define MF_RESULT_SIZE_opendir          0        /* (sizeof (DIR)) */
#undef  MF_REGISTER_readdir
#undef  MF_REGISTER_readdir
#define MF_REGISTER_gethostbyname       __MF_TYPE_STATIC
#define MF_REGISTER_gethostbyname       __MF_TYPE_STATIC
#undef  MF_REGISTER_gethostbyname_items
#undef  MF_REGISTER_gethostbyname_items
#undef  MF_REGISTER_dlopen
#undef  MF_REGISTER_dlopen
#undef  MF_REGISTER_dlerror
#undef  MF_REGISTER_dlerror
#undef  MF_REGISTER_dlsym
#undef  MF_REGISTER_dlsym
#define MF_REGISTER_shmat               __MF_TYPE_GUESS
#define MF_REGISTER_shmat               __MF_TYPE_GUESS
 
 
 
 
#include <time.h>
#include <time.h>
WRAPPER2(time_t, time, time_t *timep)
WRAPPER2(time_t, time, time_t *timep)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  if (NULL != timep)
  if (NULL != timep)
    MF_VALIDATE_EXTENT (timep, sizeof (*timep), __MF_CHECK_WRITE,
    MF_VALIDATE_EXTENT (timep, sizeof (*timep), __MF_CHECK_WRITE,
      "time timep");
      "time timep");
  return time (timep);
  return time (timep);
}
}
 
 
 
 
WRAPPER2(char *, strerror, int errnum)
WRAPPER2(char *, strerror, int errnum)
{
{
  char *p;
  char *p;
  static char * last_strerror = NULL;
  static char * last_strerror = NULL;
 
 
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  p = strerror (errnum);
  p = strerror (errnum);
  if (last_strerror != NULL)
  if (last_strerror != NULL)
    __mf_unregister (last_strerror, 0, __MF_TYPE_STATIC);
    __mf_unregister (last_strerror, 0, __MF_TYPE_STATIC);
  if (NULL != p)
  if (NULL != p)
    __mf_register (p, strlen (p) + 1, __MF_TYPE_STATIC, "strerror result");
    __mf_register (p, strlen (p) + 1, __MF_TYPE_STATIC, "strerror result");
  last_strerror = p;
  last_strerror = p;
  return p;
  return p;
}
}
 
 
 
 
 
 
/* An auxiliary data structure for tracking the hand-made stdio
/* An auxiliary data structure for tracking the hand-made stdio
   buffers we generate during the fopen/fopen64 hooks.  In a civilized
   buffers we generate during the fopen/fopen64 hooks.  In a civilized
   language, this would be a simple dynamically sized FILE*->char*
   language, this would be a simple dynamically sized FILE*->char*
   lookup table, but this is C and we get to do it by hand.  */
   lookup table, but this is C and we get to do it by hand.  */
struct mf_filebuffer
struct mf_filebuffer
{
{
  FILE *file;
  FILE *file;
  char *buffer;
  char *buffer;
  struct mf_filebuffer *next;
  struct mf_filebuffer *next;
};
};
static struct mf_filebuffer *mf_filebuffers = NULL;
static struct mf_filebuffer *mf_filebuffers = NULL;
 
 
static void
static void
mkbuffer (FILE *f)
mkbuffer (FILE *f)
{
{
  /* Reset any buffer automatically provided by libc, since this may
  /* Reset any buffer automatically provided by libc, since this may
     have been done via mechanisms that libmudflap couldn't
     have been done via mechanisms that libmudflap couldn't
     intercept.  */
     intercept.  */
  int rc;
  int rc;
  size_t bufsize = BUFSIZ;
  size_t bufsize = BUFSIZ;
  int bufmode;
  int bufmode;
  char *buffer = malloc (bufsize);
  char *buffer = malloc (bufsize);
  struct mf_filebuffer *b = malloc (sizeof (struct mf_filebuffer));
  struct mf_filebuffer *b = malloc (sizeof (struct mf_filebuffer));
  assert ((buffer != NULL) && (b != NULL));
  assert ((buffer != NULL) && (b != NULL));
 
 
  /* Link it into list.  */
  /* Link it into list.  */
  b->file = f;
  b->file = f;
  b->buffer = buffer;
  b->buffer = buffer;
  b->next = mf_filebuffers;
  b->next = mf_filebuffers;
  mf_filebuffers = b;
  mf_filebuffers = b;
 
 
  /* Determine how the file is supposed to be buffered at the moment.  */
  /* Determine how the file is supposed to be buffered at the moment.  */
  bufmode = fileno (f) == 2 ? _IONBF : (isatty (fileno (f)) ? _IOLBF : _IOFBF);
  bufmode = fileno (f) == 2 ? _IONBF : (isatty (fileno (f)) ? _IOLBF : _IOFBF);
 
 
  rc = setvbuf (f, buffer, bufmode, bufsize);
  rc = setvbuf (f, buffer, bufmode, bufsize);
  assert (rc == 0);
  assert (rc == 0);
}
}
 
 
static void
static void
unmkbuffer (FILE *f)
unmkbuffer (FILE *f)
{
{
  struct mf_filebuffer *b = mf_filebuffers;
  struct mf_filebuffer *b = mf_filebuffers;
  struct mf_filebuffer **pb = & mf_filebuffers;
  struct mf_filebuffer **pb = & mf_filebuffers;
  while (b != NULL)
  while (b != NULL)
    {
    {
      if (b->file == f)
      if (b->file == f)
        {
        {
          *pb = b->next;
          *pb = b->next;
          free (b->buffer);
          free (b->buffer);
          free (b);
          free (b);
          return;
          return;
        }
        }
      pb = & b->next;
      pb = & b->next;
      b = b->next;
      b = b->next;
    }
    }
}
}
 
 
 
 
 
 
WRAPPER2(FILE *, fopen, const char *path, const char *mode)
WRAPPER2(FILE *, fopen, const char *path, const char *mode)
{
{
  size_t n;
  size_t n;
  FILE *p;
  FILE *p;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
 
 
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "fopen path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "fopen path");
 
 
  n = strlen (mode);
  n = strlen (mode);
  MF_VALIDATE_EXTENT (mode, CLAMPADD(n, 1), __MF_CHECK_READ, "fopen mode");
  MF_VALIDATE_EXTENT (mode, CLAMPADD(n, 1), __MF_CHECK_READ, "fopen mode");
 
 
  p = fopen (path, mode);
  p = fopen (path, mode);
  if (NULL != p) {
  if (NULL != p) {
#ifdef MF_REGISTER_fopen
#ifdef MF_REGISTER_fopen
    __mf_register (p, sizeof (*p), MF_REGISTER_fopen, "fopen result");
    __mf_register (p, sizeof (*p), MF_REGISTER_fopen, "fopen result");
#endif
#endif
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "fopen result");
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "fopen result");
 
 
    mkbuffer (p);
    mkbuffer (p);
  }
  }
 
 
  return p;
  return p;
}
}
 
 
 
 
WRAPPER2(int, setvbuf, FILE *stream, char *buf, int mode, size_t size)
WRAPPER2(int, setvbuf, FILE *stream, char *buf, int mode, size_t size)
{
{
  int rc = 0;
  int rc = 0;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
 
 
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE, "setvbuf stream");
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE, "setvbuf stream");
 
 
  unmkbuffer (stream);
  unmkbuffer (stream);
 
 
  if (buf != NULL)
  if (buf != NULL)
    MF_VALIDATE_EXTENT (buf, size, __MF_CHECK_WRITE, "setvbuf buffer");
    MF_VALIDATE_EXTENT (buf, size, __MF_CHECK_WRITE, "setvbuf buffer");
 
 
  /* Override the user only if it's an auto-allocated buffer request.  Otherwise
  /* Override the user only if it's an auto-allocated buffer request.  Otherwise
     assume that the supplied buffer is already known to libmudflap.  */
     assume that the supplied buffer is already known to libmudflap.  */
  if ((buf == NULL) && ((mode == _IOFBF) || (mode == _IOLBF)))
  if ((buf == NULL) && ((mode == _IOFBF) || (mode == _IOLBF)))
    mkbuffer (stream);
    mkbuffer (stream);
  else
  else
    rc = setvbuf (stream, buf, mode, size);
    rc = setvbuf (stream, buf, mode, size);
 
 
  return rc;
  return rc;
}
}
 
 
 
 
#ifdef HAVE_SETBUF
#ifdef HAVE_SETBUF
WRAPPER2(int, setbuf, FILE* stream, char *buf)
WRAPPER2(int, setbuf, FILE* stream, char *buf)
{
{
  return __mfwrap_setvbuf (stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
  return __mfwrap_setvbuf (stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
}
}
#endif
#endif
 
 
#ifdef HAVE_SETBUFFER
#ifdef HAVE_SETBUFFER
WRAPPER2(int, setbuffer, FILE* stream, char *buf, size_t sz)
WRAPPER2(int, setbuffer, FILE* stream, char *buf, size_t sz)
{
{
  return __mfwrap_setvbuf (stream, buf, buf ? _IOFBF : _IONBF, sz);
  return __mfwrap_setvbuf (stream, buf, buf ? _IOFBF : _IONBF, sz);
}
}
#endif
#endif
 
 
#ifdef HAVE_SETLINEBUF
#ifdef HAVE_SETLINEBUF
WRAPPER2(int, setlinebuf, FILE* stream)
WRAPPER2(int, setlinebuf, FILE* stream)
{
{
  return __mfwrap_setvbuf(stream, NULL, _IOLBF, 0);
  return __mfwrap_setvbuf(stream, NULL, _IOLBF, 0);
}
}
#endif
#endif
 
 
 
 
 
 
WRAPPER2(FILE *, fdopen, int fd, const char *mode)
WRAPPER2(FILE *, fdopen, int fd, const char *mode)
{
{
  size_t n;
  size_t n;
  FILE *p;
  FILE *p;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
 
 
  n = strlen (mode);
  n = strlen (mode);
  MF_VALIDATE_EXTENT (mode, CLAMPADD(n, 1), __MF_CHECK_READ, "fdopen mode");
  MF_VALIDATE_EXTENT (mode, CLAMPADD(n, 1), __MF_CHECK_READ, "fdopen mode");
 
 
  p = fdopen (fd, mode);
  p = fdopen (fd, mode);
  if (NULL != p) {
  if (NULL != p) {
#ifdef MF_REGISTER_fopen
#ifdef MF_REGISTER_fopen
    __mf_register (p, sizeof (*p), MF_REGISTER_fopen, "fdopen result");
    __mf_register (p, sizeof (*p), MF_REGISTER_fopen, "fdopen result");
#endif
#endif
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "fdopen result");
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "fdopen result");
 
 
    mkbuffer (p);
    mkbuffer (p);
  }
  }
 
 
  return p;
  return p;
}
}
 
 
 
 
WRAPPER2(FILE *, freopen, const char *path, const char *mode, FILE *s)
WRAPPER2(FILE *, freopen, const char *path, const char *mode, FILE *s)
{
{
  size_t n;
  size_t n;
  FILE *p;
  FILE *p;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
 
 
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "freopen path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "freopen path");
 
 
  MF_VALIDATE_EXTENT (s, (sizeof (*s)), __MF_CHECK_WRITE, "freopen stream");
  MF_VALIDATE_EXTENT (s, (sizeof (*s)), __MF_CHECK_WRITE, "freopen stream");
  unmkbuffer (s);
  unmkbuffer (s);
 
 
  n = strlen (mode);
  n = strlen (mode);
  MF_VALIDATE_EXTENT (mode, CLAMPADD(n, 1), __MF_CHECK_READ, "freopen mode");
  MF_VALIDATE_EXTENT (mode, CLAMPADD(n, 1), __MF_CHECK_READ, "freopen mode");
 
 
  p = freopen (path, mode, s);
  p = freopen (path, mode, s);
  if (NULL != p) {
  if (NULL != p) {
#ifdef MF_REGISTER_fopen
#ifdef MF_REGISTER_fopen
    __mf_register (p, sizeof (*p), MF_REGISTER_fopen, "freopen result");
    __mf_register (p, sizeof (*p), MF_REGISTER_fopen, "freopen result");
#endif
#endif
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "freopen result");
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "freopen result");
 
 
    mkbuffer (p);
    mkbuffer (p);
  }
  }
 
 
  return p;
  return p;
}
}
 
 
 
 
#ifdef HAVE_FOPEN64
#ifdef HAVE_FOPEN64
WRAPPER2(FILE *, fopen64, const char *path, const char *mode)
WRAPPER2(FILE *, fopen64, const char *path, const char *mode)
{
{
  size_t n;
  size_t n;
  FILE *p;
  FILE *p;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
 
 
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "fopen64 path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "fopen64 path");
 
 
  n = strlen (mode);
  n = strlen (mode);
  MF_VALIDATE_EXTENT (mode, CLAMPADD(n, 1), __MF_CHECK_READ, "fopen64 mode");
  MF_VALIDATE_EXTENT (mode, CLAMPADD(n, 1), __MF_CHECK_READ, "fopen64 mode");
 
 
  p = fopen64 (path, mode);
  p = fopen64 (path, mode);
  if (NULL != p) {
  if (NULL != p) {
#ifdef MF_REGISTER_fopen
#ifdef MF_REGISTER_fopen
    __mf_register (p, sizeof (*p), MF_REGISTER_fopen, "fopen64 result");
    __mf_register (p, sizeof (*p), MF_REGISTER_fopen, "fopen64 result");
#endif
#endif
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "fopen64 result");
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "fopen64 result");
 
 
    mkbuffer (p);
    mkbuffer (p);
  }
  }
 
 
  return p;
  return p;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_FREOPEN64
#ifdef HAVE_FREOPEN64
WRAPPER2(FILE *, freopen64, const char *path, const char *mode, FILE *s)
WRAPPER2(FILE *, freopen64, const char *path, const char *mode, FILE *s)
{
{
  size_t n;
  size_t n;
  FILE *p;
  FILE *p;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
 
 
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "freopen64 path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "freopen64 path");
 
 
  MF_VALIDATE_EXTENT (s, (sizeof (*s)), __MF_CHECK_WRITE, "freopen64 stream");
  MF_VALIDATE_EXTENT (s, (sizeof (*s)), __MF_CHECK_WRITE, "freopen64 stream");
  unmkbuffer (s);
  unmkbuffer (s);
 
 
  n = strlen (mode);
  n = strlen (mode);
  MF_VALIDATE_EXTENT (mode, CLAMPADD(n, 1), __MF_CHECK_READ, "freopen64 mode");
  MF_VALIDATE_EXTENT (mode, CLAMPADD(n, 1), __MF_CHECK_READ, "freopen64 mode");
 
 
  p = freopen (path, mode, s);
  p = freopen (path, mode, s);
  if (NULL != p) {
  if (NULL != p) {
#ifdef MF_REGISTER_fopen
#ifdef MF_REGISTER_fopen
    __mf_register (p, sizeof (*p), MF_REGISTER_fopen, "freopen64 result");
    __mf_register (p, sizeof (*p), MF_REGISTER_fopen, "freopen64 result");
#endif
#endif
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "freopen64 result");
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "freopen64 result");
 
 
    mkbuffer (p);
    mkbuffer (p);
  }
  }
 
 
  return p;
  return p;
}
}
#endif
#endif
 
 
 
 
WRAPPER2(int, fclose, FILE *stream)
WRAPPER2(int, fclose, FILE *stream)
{
{
  int resp;
  int resp;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "fclose stream");
    "fclose stream");
  resp = fclose (stream);
  resp = fclose (stream);
#ifdef MF_REGISTER_fopen
#ifdef MF_REGISTER_fopen
  __mf_unregister (stream, sizeof (*stream), MF_REGISTER_fopen);
  __mf_unregister (stream, sizeof (*stream), MF_REGISTER_fopen);
#endif
#endif
  unmkbuffer (stream);
  unmkbuffer (stream);
 
 
  return resp;
  return resp;
}
}
 
 
 
 
WRAPPER2(size_t, fread, void *ptr, size_t size, size_t nmemb, FILE *stream)
WRAPPER2(size_t, fread, void *ptr, size_t size, size_t nmemb, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "fread stream");
    "fread stream");
  MF_VALIDATE_EXTENT (ptr, size * nmemb, __MF_CHECK_WRITE, "fread buffer");
  MF_VALIDATE_EXTENT (ptr, size * nmemb, __MF_CHECK_WRITE, "fread buffer");
  return fread (ptr, size, nmemb, stream);
  return fread (ptr, size, nmemb, stream);
}
}
 
 
 
 
WRAPPER2(size_t, fwrite, const void *ptr, size_t size, size_t nmemb,
WRAPPER2(size_t, fwrite, const void *ptr, size_t size, size_t nmemb,
        FILE *stream)
        FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "fwrite stream");
    "fwrite stream");
  MF_VALIDATE_EXTENT (ptr, size * nmemb, __MF_CHECK_READ, "fwrite buffer");
  MF_VALIDATE_EXTENT (ptr, size * nmemb, __MF_CHECK_READ, "fwrite buffer");
  return fwrite (ptr, size, nmemb, stream);
  return fwrite (ptr, size, nmemb, stream);
}
}
 
 
 
 
WRAPPER2(int, fgetc, FILE *stream)
WRAPPER2(int, fgetc, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "fgetc stream");
    "fgetc stream");
  return fgetc (stream);
  return fgetc (stream);
}
}
 
 
 
 
WRAPPER2(char *, fgets, char *s, int size, FILE *stream)
WRAPPER2(char *, fgets, char *s, int size, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "fgets stream");
    "fgets stream");
  MF_VALIDATE_EXTENT (s, size, __MF_CHECK_WRITE, "fgets buffer");
  MF_VALIDATE_EXTENT (s, size, __MF_CHECK_WRITE, "fgets buffer");
  return fgets (s, size, stream);
  return fgets (s, size, stream);
}
}
 
 
 
 
WRAPPER2(int, getc, FILE *stream)
WRAPPER2(int, getc, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "getc stream");
    "getc stream");
  return getc (stream);
  return getc (stream);
}
}
 
 
 
 
WRAPPER2(char *, gets, char *s)
WRAPPER2(char *, gets, char *s)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (s, 1, __MF_CHECK_WRITE, "gets buffer");
  MF_VALIDATE_EXTENT (s, 1, __MF_CHECK_WRITE, "gets buffer");
  /* Avoid link-time warning... */
  /* Avoid link-time warning... */
  s = fgets (s, INT_MAX, stdin);
  s = fgets (s, INT_MAX, stdin);
  if (NULL != s) {      /* better late than never */
  if (NULL != s) {      /* better late than never */
    size_t n = strlen (s);
    size_t n = strlen (s);
    MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_WRITE, "gets buffer");
    MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_WRITE, "gets buffer");
  }
  }
  return s;
  return s;
}
}
 
 
 
 
WRAPPER2(int, ungetc, int c, FILE *stream)
WRAPPER2(int, ungetc, int c, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
     "ungetc stream");
     "ungetc stream");
  return ungetc (c, stream);
  return ungetc (c, stream);
}
}
 
 
 
 
WRAPPER2(int, fputc, int c, FILE *stream)
WRAPPER2(int, fputc, int c, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "fputc stream");
    "fputc stream");
  return fputc (c, stream);
  return fputc (c, stream);
}
}
 
 
 
 
WRAPPER2(int, fputs, const char *s, FILE *stream)
WRAPPER2(int, fputs, const char *s, FILE *stream)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (s);
  n = strlen (s);
  MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_READ, "fputs buffer");
  MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_READ, "fputs buffer");
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "fputs stream");
    "fputs stream");
  return fputs (s, stream);
  return fputs (s, stream);
}
}
 
 
 
 
WRAPPER2(int, putc, int c, FILE *stream)
WRAPPER2(int, putc, int c, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "putc stream");
    "putc stream");
  return putc (c, stream);
  return putc (c, stream);
}
}
 
 
 
 
WRAPPER2(int, puts, const char *s)
WRAPPER2(int, puts, const char *s)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (s);
  n = strlen (s);
  MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_READ, "puts buffer");
  MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_READ, "puts buffer");
  return puts (s);
  return puts (s);
}
}
 
 
 
 
WRAPPER2(void, clearerr, FILE *stream)
WRAPPER2(void, clearerr, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "clearerr stream");
    "clearerr stream");
  clearerr (stream);
  clearerr (stream);
}
}
 
 
 
 
WRAPPER2(int, feof, FILE *stream)
WRAPPER2(int, feof, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "feof stream");
    "feof stream");
  return feof (stream);
  return feof (stream);
}
}
 
 
 
 
WRAPPER2(int, ferror, FILE *stream)
WRAPPER2(int, ferror, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "ferror stream");
    "ferror stream");
  return ferror (stream);
  return ferror (stream);
}
}
 
 
 
 
WRAPPER2(int, fileno, FILE *stream)
WRAPPER2(int, fileno, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "fileno stream");
    "fileno stream");
  return fileno (stream);
  return fileno (stream);
}
}
 
 
 
 
WRAPPER2(int, printf, const char *format, ...)
WRAPPER2(int, printf, const char *format, ...)
{
{
  size_t n;
  size_t n;
  va_list ap;
  va_list ap;
  int result;
  int result;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (format);
  n = strlen (format);
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
    "printf format");
    "printf format");
  va_start (ap, format);
  va_start (ap, format);
  result = vprintf (format, ap);
  result = vprintf (format, ap);
  va_end (ap);
  va_end (ap);
  return result;
  return result;
}
}
 
 
 
 
WRAPPER2(int, fprintf, FILE *stream, const char *format, ...)
WRAPPER2(int, fprintf, FILE *stream, const char *format, ...)
{
{
  size_t n;
  size_t n;
  va_list ap;
  va_list ap;
  int result;
  int result;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "fprintf stream");
    "fprintf stream");
  n = strlen (format);
  n = strlen (format);
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
    "fprintf format");
    "fprintf format");
  va_start (ap, format);
  va_start (ap, format);
  result = vfprintf (stream, format, ap);
  result = vfprintf (stream, format, ap);
  va_end (ap);
  va_end (ap);
  return result;
  return result;
}
}
 
 
 
 
WRAPPER2(int, sprintf, char *str, const char *format, ...)
WRAPPER2(int, sprintf, char *str, const char *format, ...)
{
{
  size_t n;
  size_t n;
  va_list ap;
  va_list ap;
  int result;
  int result;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (str, 1, __MF_CHECK_WRITE, "sprintf str");
  MF_VALIDATE_EXTENT (str, 1, __MF_CHECK_WRITE, "sprintf str");
  n = strlen (format);
  n = strlen (format);
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
    "sprintf format");
    "sprintf format");
  va_start (ap, format);
  va_start (ap, format);
  result = vsprintf (str, format, ap);
  result = vsprintf (str, format, ap);
  va_end (ap);
  va_end (ap);
  n = strlen (str);
  n = strlen (str);
  MF_VALIDATE_EXTENT (str, CLAMPADD(n, 1), __MF_CHECK_WRITE, "sprintf str");
  MF_VALIDATE_EXTENT (str, CLAMPADD(n, 1), __MF_CHECK_WRITE, "sprintf str");
  return result;
  return result;
}
}
 
 
 
 
WRAPPER2(int, snprintf, char *str, size_t size, const char *format, ...)
WRAPPER2(int, snprintf, char *str, size_t size, const char *format, ...)
{
{
  size_t n;
  size_t n;
  va_list ap;
  va_list ap;
  int result;
  int result;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (str, size, __MF_CHECK_WRITE, "snprintf str");
  MF_VALIDATE_EXTENT (str, size, __MF_CHECK_WRITE, "snprintf str");
  n = strlen (format);
  n = strlen (format);
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
    "snprintf format");
    "snprintf format");
  va_start (ap, format);
  va_start (ap, format);
  result = vsnprintf (str, size, format, ap);
  result = vsnprintf (str, size, format, ap);
  va_end (ap);
  va_end (ap);
  return result;
  return result;
}
}
 
 
 
 
WRAPPER2(int, vprintf,  const char *format, va_list ap)
WRAPPER2(int, vprintf,  const char *format, va_list ap)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (format);
  n = strlen (format);
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
    "vprintf format");
    "vprintf format");
  return vprintf (format, ap);
  return vprintf (format, ap);
}
}
 
 
 
 
WRAPPER2(int, vfprintf, FILE *stream, const char *format, va_list ap)
WRAPPER2(int, vfprintf, FILE *stream, const char *format, va_list ap)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "vfprintf stream");
    "vfprintf stream");
  n = strlen (format);
  n = strlen (format);
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
    "vfprintf format");
    "vfprintf format");
  return vfprintf (stream, format, ap);
  return vfprintf (stream, format, ap);
}
}
 
 
 
 
WRAPPER2(int, vsprintf, char *str, const char *format, va_list ap)
WRAPPER2(int, vsprintf, char *str, const char *format, va_list ap)
{
{
  size_t n;
  size_t n;
  int result;
  int result;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (str, 1, __MF_CHECK_WRITE, "vsprintf str");
  MF_VALIDATE_EXTENT (str, 1, __MF_CHECK_WRITE, "vsprintf str");
  n = strlen (format);
  n = strlen (format);
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
    "vsprintf format");
    "vsprintf format");
  result = vsprintf (str, format, ap);
  result = vsprintf (str, format, ap);
  n = strlen (str);
  n = strlen (str);
  MF_VALIDATE_EXTENT (str, CLAMPADD(n, 1), __MF_CHECK_WRITE, "vsprintf str");
  MF_VALIDATE_EXTENT (str, CLAMPADD(n, 1), __MF_CHECK_WRITE, "vsprintf str");
  return result;
  return result;
}
}
 
 
 
 
WRAPPER2(int, vsnprintf, char *str, size_t size, const char *format,
WRAPPER2(int, vsnprintf, char *str, size_t size, const char *format,
        va_list ap)
        va_list ap)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (str, size, __MF_CHECK_WRITE, "vsnprintf str");
  MF_VALIDATE_EXTENT (str, size, __MF_CHECK_WRITE, "vsnprintf str");
  n = strlen (format);
  n = strlen (format);
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
  MF_VALIDATE_EXTENT (format, CLAMPADD(n, 1), __MF_CHECK_READ,
    "vsnprintf format");
    "vsnprintf format");
  return vsnprintf (str, size, format, ap);
  return vsnprintf (str, size, format, ap);
}
}
 
 
 
 
WRAPPER2(int , access, const char *path, int mode)
WRAPPER2(int , access, const char *path, int mode)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "access path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "access path");
  return access (path, mode);
  return access (path, mode);
}
}
 
 
 
 
WRAPPER2(int , remove, const char *path)
WRAPPER2(int , remove, const char *path)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "remove path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "remove path");
  return remove (path);
  return remove (path);
}
}
 
 
 
 
WRAPPER2(int, fflush, FILE *stream)
WRAPPER2(int, fflush, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  if (stream != NULL)
  if (stream != NULL)
    MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
                        "fflush stream");
                        "fflush stream");
  return fflush (stream);
  return fflush (stream);
}
}
 
 
 
 
WRAPPER2(int, fseek, FILE *stream, long offset, int whence)
WRAPPER2(int, fseek, FILE *stream, long offset, int whence)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "fseek stream");
    "fseek stream");
  return fseek (stream, offset, whence);
  return fseek (stream, offset, whence);
}
}
 
 
 
 
#ifdef HAVE_FSEEKO64
#ifdef HAVE_FSEEKO64
WRAPPER2(int, fseeko64, FILE *stream, off64_t offset, int whence)
WRAPPER2(int, fseeko64, FILE *stream, off64_t offset, int whence)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "fseeko64 stream");
    "fseeko64 stream");
  return fseeko64 (stream, offset, whence);
  return fseeko64 (stream, offset, whence);
}
}
#endif
#endif
 
 
 
 
WRAPPER2(long, ftell, FILE *stream)
WRAPPER2(long, ftell, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "ftell stream");
    "ftell stream");
  return ftell (stream);
  return ftell (stream);
}
}
 
 
 
 
#ifdef HAVE_FTELLO64
#ifdef HAVE_FTELLO64
WRAPPER2(off64_t, ftello64, FILE *stream)
WRAPPER2(off64_t, ftello64, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "ftello64 stream");
    "ftello64 stream");
  return ftello64 (stream);
  return ftello64 (stream);
}
}
#endif
#endif
 
 
 
 
WRAPPER2(void, rewind, FILE *stream)
WRAPPER2(void, rewind, FILE *stream)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "rewind stream");
    "rewind stream");
  rewind (stream);
  rewind (stream);
}
}
 
 
 
 
WRAPPER2(int, fgetpos, FILE *stream, fpos_t *pos)
WRAPPER2(int, fgetpos, FILE *stream, fpos_t *pos)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "fgetpos stream");
    "fgetpos stream");
  MF_VALIDATE_EXTENT (pos, sizeof (*pos), __MF_CHECK_WRITE, "fgetpos pos");
  MF_VALIDATE_EXTENT (pos, sizeof (*pos), __MF_CHECK_WRITE, "fgetpos pos");
  return fgetpos (stream, pos);
  return fgetpos (stream, pos);
}
}
 
 
 
 
WRAPPER2(int, fsetpos, FILE *stream, fpos_t *pos)
WRAPPER2(int, fsetpos, FILE *stream, fpos_t *pos)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "fsetpos stream");
    "fsetpos stream");
  MF_VALIDATE_EXTENT (pos, sizeof (*pos), __MF_CHECK_READ, "fsetpos pos");
  MF_VALIDATE_EXTENT (pos, sizeof (*pos), __MF_CHECK_READ, "fsetpos pos");
  return fsetpos (stream, pos);
  return fsetpos (stream, pos);
}
}
 
 
 
 
WRAPPER2(int , stat, const char *path, struct stat *buf)
WRAPPER2(int , stat, const char *path, struct stat *buf)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "stat path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "stat path");
  MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_READ, "stat buf");
  MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_READ, "stat buf");
  return stat (path, buf);
  return stat (path, buf);
}
}
 
 
 
 
#ifdef HAVE_STAT64
#ifdef HAVE_STAT64
WRAPPER2(int , stat64, const char *path, struct stat64 *buf)
WRAPPER2(int , stat64, const char *path, struct stat64 *buf)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "stat64 path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "stat64 path");
  MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_READ, "stat64 buf");
  MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_READ, "stat64 buf");
  return stat64 (path, buf);
  return stat64 (path, buf);
}
}
#endif
#endif
 
 
 
 
WRAPPER2(int , fstat, int filedes, struct stat *buf)
WRAPPER2(int , fstat, int filedes, struct stat *buf)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_READ, "fstat buf");
  MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_READ, "fstat buf");
  return fstat (filedes, buf);
  return fstat (filedes, buf);
}
}
 
 
 
 
WRAPPER2(int , lstat, const char *path, struct stat *buf)
WRAPPER2(int , lstat, const char *path, struct stat *buf)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "lstat path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "lstat path");
  MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_READ, "lstat buf");
  MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_READ, "lstat buf");
  return lstat (path, buf);
  return lstat (path, buf);
}
}
 
 
 
 
WRAPPER2(int , mkfifo, const char *path, mode_t mode)
WRAPPER2(int , mkfifo, const char *path, mode_t mode)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "mkfifo path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "mkfifo path");
  return mkfifo (path, mode);
  return mkfifo (path, mode);
}
}
 
 
 
 
#ifdef HAVE_DIRENT_H
#ifdef HAVE_DIRENT_H
WRAPPER2(DIR *, opendir, const char *path)
WRAPPER2(DIR *, opendir, const char *path)
{
{
  DIR *p;
  DIR *p;
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "opendir path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "opendir path");
 
 
  p = opendir (path);
  p = opendir (path);
  if (NULL != p) {
  if (NULL != p) {
#ifdef MF_REGISTER_opendir
#ifdef MF_REGISTER_opendir
    __mf_register (p, MF_RESULT_SIZE_opendir, MF_REGISTER_opendir,
    __mf_register (p, MF_RESULT_SIZE_opendir, MF_REGISTER_opendir,
      "opendir result");
      "opendir result");
#endif
#endif
    MF_VALIDATE_EXTENT (p, MF_RESULT_SIZE_opendir, __MF_CHECK_WRITE,
    MF_VALIDATE_EXTENT (p, MF_RESULT_SIZE_opendir, __MF_CHECK_WRITE,
      "opendir result");
      "opendir result");
  }
  }
  return p;
  return p;
}
}
 
 
 
 
WRAPPER2(int, closedir, DIR *dir)
WRAPPER2(int, closedir, DIR *dir)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (dir, 0, __MF_CHECK_WRITE, "closedir dir");
  MF_VALIDATE_EXTENT (dir, 0, __MF_CHECK_WRITE, "closedir dir");
#ifdef MF_REGISTER_opendir
#ifdef MF_REGISTER_opendir
  __mf_unregister (dir, MF_RESULT_SIZE_opendir, MF_REGISTER_opendir);
  __mf_unregister (dir, MF_RESULT_SIZE_opendir, MF_REGISTER_opendir);
#endif
#endif
  return closedir (dir);
  return closedir (dir);
}
}
 
 
 
 
WRAPPER2(struct dirent *, readdir, DIR *dir)
WRAPPER2(struct dirent *, readdir, DIR *dir)
{
{
  struct dirent *p;
  struct dirent *p;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (dir, 0, __MF_CHECK_READ, "readdir dir");
  MF_VALIDATE_EXTENT (dir, 0, __MF_CHECK_READ, "readdir dir");
  p = readdir (dir);
  p = readdir (dir);
  if (NULL != p) {
  if (NULL != p) {
#ifdef MF_REGISTER_readdir
#ifdef MF_REGISTER_readdir
    __mf_register (p, sizeof (*p), MF_REGISTER_readdir, "readdir result");
    __mf_register (p, sizeof (*p), MF_REGISTER_readdir, "readdir result");
#endif
#endif
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "readdir result");
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "readdir result");
  }
  }
  return p;
  return p;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_SYS_SOCKET_H
#ifdef HAVE_SYS_SOCKET_H
 
 
WRAPPER2(int, recv, int s, void *buf, size_t len, int flags)
WRAPPER2(int, recv, int s, void *buf, size_t len, int flags)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (buf, len, __MF_CHECK_WRITE, "recv buf");
  MF_VALIDATE_EXTENT (buf, len, __MF_CHECK_WRITE, "recv buf");
  return recv (s, buf, len, flags);
  return recv (s, buf, len, flags);
}
}
 
 
 
 
WRAPPER2(int, recvfrom, int s, void *buf, size_t len, int flags,
WRAPPER2(int, recvfrom, int s, void *buf, size_t len, int flags,
                struct sockaddr *from, socklen_t *fromlen)
                struct sockaddr *from, socklen_t *fromlen)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (buf, len, __MF_CHECK_WRITE, "recvfrom buf");
  MF_VALIDATE_EXTENT (buf, len, __MF_CHECK_WRITE, "recvfrom buf");
  MF_VALIDATE_EXTENT (from, (size_t)*fromlen, __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (from, (size_t)*fromlen, __MF_CHECK_WRITE,
    "recvfrom from");
    "recvfrom from");
  return recvfrom (s, buf, len, flags, from, fromlen);
  return recvfrom (s, buf, len, flags, from, fromlen);
}
}
 
 
 
 
WRAPPER2(int, recvmsg, int s, struct msghdr *msg, int flags)
WRAPPER2(int, recvmsg, int s, struct msghdr *msg, int flags)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (msg, sizeof (*msg), __MF_CHECK_WRITE, "recvmsg msg");
  MF_VALIDATE_EXTENT (msg, sizeof (*msg), __MF_CHECK_WRITE, "recvmsg msg");
  return recvmsg (s, msg, flags);
  return recvmsg (s, msg, flags);
}
}
 
 
 
 
WRAPPER2(int, send, int s, const void *msg, size_t len, int flags)
WRAPPER2(int, send, int s, const void *msg, size_t len, int flags)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (msg, len, __MF_CHECK_READ, "send msg");
  MF_VALIDATE_EXTENT (msg, len, __MF_CHECK_READ, "send msg");
  return send (s, msg, len, flags);
  return send (s, msg, len, flags);
}
}
 
 
 
 
WRAPPER2(int, sendto, int s, const void *msg, size_t len, int flags,
WRAPPER2(int, sendto, int s, const void *msg, size_t len, int flags,
                const struct sockaddr *to, socklen_t tolen)
                const struct sockaddr *to, socklen_t tolen)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (msg, len, __MF_CHECK_READ, "sendto msg");
  MF_VALIDATE_EXTENT (msg, len, __MF_CHECK_READ, "sendto msg");
  MF_VALIDATE_EXTENT (to, (size_t)tolen, __MF_CHECK_WRITE, "sendto to");
  MF_VALIDATE_EXTENT (to, (size_t)tolen, __MF_CHECK_WRITE, "sendto to");
  return sendto (s, msg, len, flags, to, tolen);
  return sendto (s, msg, len, flags, to, tolen);
}
}
 
 
 
 
WRAPPER2(int, sendmsg, int s, const void *msg, int flags)
WRAPPER2(int, sendmsg, int s, const void *msg, int flags)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (msg, sizeof (*msg), __MF_CHECK_READ, "sendmsg msg");
  MF_VALIDATE_EXTENT (msg, sizeof (*msg), __MF_CHECK_READ, "sendmsg msg");
  return sendmsg (s, msg, flags);
  return sendmsg (s, msg, flags);
}
}
 
 
 
 
WRAPPER2(int, setsockopt, int s, int level, int optname, const void *optval,
WRAPPER2(int, setsockopt, int s, int level, int optname, const void *optval,
        socklen_t optlen)
        socklen_t optlen)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (optval, (size_t)optlen, __MF_CHECK_READ,
  MF_VALIDATE_EXTENT (optval, (size_t)optlen, __MF_CHECK_READ,
    "setsockopt optval");
    "setsockopt optval");
  return setsockopt (s, level, optname, optval, optlen);
  return setsockopt (s, level, optname, optval, optlen);
}
}
 
 
 
 
WRAPPER2(int, getsockopt, int s, int level, int optname, void *optval,
WRAPPER2(int, getsockopt, int s, int level, int optname, void *optval,
                socklen_t *optlen)
                socklen_t *optlen)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (optval, (size_t)*optlen, __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (optval, (size_t)*optlen, __MF_CHECK_WRITE,
    "getsockopt optval");
    "getsockopt optval");
  return getsockopt (s, level, optname, optval, optlen);
  return getsockopt (s, level, optname, optval, optlen);
}
}
 
 
 
 
WRAPPER2(int, accept, int s, struct  sockaddr *addr, socklen_t *addrlen)
WRAPPER2(int, accept, int s, struct  sockaddr *addr, socklen_t *addrlen)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  if (addr != NULL)
  if (addr != NULL)
    MF_VALIDATE_EXTENT (addr, (size_t)*addrlen, __MF_CHECK_WRITE, "accept addr");
    MF_VALIDATE_EXTENT (addr, (size_t)*addrlen, __MF_CHECK_WRITE, "accept addr");
  return accept (s, addr, addrlen);
  return accept (s, addr, addrlen);
}
}
 
 
 
 
WRAPPER2(int, bind, int sockfd, struct  sockaddr *addr, socklen_t addrlen)
WRAPPER2(int, bind, int sockfd, struct  sockaddr *addr, socklen_t addrlen)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (addr, (size_t)addrlen, __MF_CHECK_WRITE, "bind addr");
  MF_VALIDATE_EXTENT (addr, (size_t)addrlen, __MF_CHECK_WRITE, "bind addr");
  return bind (sockfd, addr, addrlen);
  return bind (sockfd, addr, addrlen);
}
}
 
 
 
 
WRAPPER2(int, connect, int sockfd, const struct sockaddr  *addr,
WRAPPER2(int, connect, int sockfd, const struct sockaddr  *addr,
        socklen_t addrlen)
        socklen_t addrlen)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (addr, (size_t)addrlen, __MF_CHECK_READ,
  MF_VALIDATE_EXTENT (addr, (size_t)addrlen, __MF_CHECK_READ,
    "connect addr");
    "connect addr");
  return connect (sockfd, addr, addrlen);
  return connect (sockfd, addr, addrlen);
}
}
 
 
#endif /* HAVE_SYS_SOCKET_H */
#endif /* HAVE_SYS_SOCKET_H */
 
 
 
 
WRAPPER2(int, gethostname, char *name, size_t len)
WRAPPER2(int, gethostname, char *name, size_t len)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (name, len, __MF_CHECK_WRITE, "gethostname name");
  MF_VALIDATE_EXTENT (name, len, __MF_CHECK_WRITE, "gethostname name");
  return gethostname (name, len);
  return gethostname (name, len);
}
}
 
 
 
 
#ifdef HAVE_SETHOSTNAME
#ifdef HAVE_SETHOSTNAME
WRAPPER2(int, sethostname, const char *name, size_t len)
WRAPPER2(int, sethostname, const char *name, size_t len)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (name, len, __MF_CHECK_READ, "sethostname name");
  MF_VALIDATE_EXTENT (name, len, __MF_CHECK_READ, "sethostname name");
  return sethostname (name, len);
  return sethostname (name, len);
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_NETDB_H
#ifdef HAVE_NETDB_H
 
 
WRAPPER2(struct hostent *, gethostbyname, const char *name)
WRAPPER2(struct hostent *, gethostbyname, const char *name)
{
{
  struct hostent *p;
  struct hostent *p;
  char **ss;
  char **ss;
  char *s;
  char *s;
  size_t n;
  size_t n;
  int nreg;
  int nreg;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (name);
  n = strlen (name);
  MF_VALIDATE_EXTENT (name, CLAMPADD(n, 1), __MF_CHECK_READ,
  MF_VALIDATE_EXTENT (name, CLAMPADD(n, 1), __MF_CHECK_READ,
    "gethostbyname name");
    "gethostbyname name");
  p = gethostbyname (name);
  p = gethostbyname (name);
  if (NULL != p) {
  if (NULL != p) {
#ifdef MF_REGISTER_gethostbyname
#ifdef MF_REGISTER_gethostbyname
    __mf_register (p, sizeof (*p), MF_REGISTER_gethostbyname,
    __mf_register (p, sizeof (*p), MF_REGISTER_gethostbyname,
      "gethostbyname result");
      "gethostbyname result");
#endif
#endif
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE,
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE,
      "gethostbyname result");
      "gethostbyname result");
    if (NULL != (s = p->h_name)) {
    if (NULL != (s = p->h_name)) {
      n = strlen (s);
      n = strlen (s);
      n = CLAMPADD(n, 1);
      n = CLAMPADD(n, 1);
#ifdef MF_REGISTER_gethostbyname_items
#ifdef MF_REGISTER_gethostbyname_items
      __mf_register (s, n, MF_REGISTER_gethostbyname_items,
      __mf_register (s, n, MF_REGISTER_gethostbyname_items,
        "gethostbyname result->h_name");
        "gethostbyname result->h_name");
#endif
#endif
      MF_VALIDATE_EXTENT (s, n, __MF_CHECK_WRITE,
      MF_VALIDATE_EXTENT (s, n, __MF_CHECK_WRITE,
        "gethostbyname result->h_name");
        "gethostbyname result->h_name");
    }
    }
 
 
    if (NULL != (ss = p->h_aliases)) {
    if (NULL != (ss = p->h_aliases)) {
      for (nreg = 1;; ++nreg) {
      for (nreg = 1;; ++nreg) {
        s = *ss++;
        s = *ss++;
        if (NULL == s)
        if (NULL == s)
          break;
          break;
        n = strlen (s);
        n = strlen (s);
        n = CLAMPADD(n, 1);
        n = CLAMPADD(n, 1);
#ifdef MF_REGISTER_gethostbyname_items
#ifdef MF_REGISTER_gethostbyname_items
        __mf_register (s, n, MF_REGISTER_gethostbyname_items,
        __mf_register (s, n, MF_REGISTER_gethostbyname_items,
          "gethostbyname result->h_aliases[]");
          "gethostbyname result->h_aliases[]");
#endif
#endif
        MF_VALIDATE_EXTENT (s, n, __MF_CHECK_WRITE,
        MF_VALIDATE_EXTENT (s, n, __MF_CHECK_WRITE,
          "gethostbyname result->h_aliases[]");
          "gethostbyname result->h_aliases[]");
      }
      }
      nreg *= sizeof (*p->h_aliases);
      nreg *= sizeof (*p->h_aliases);
#ifdef MF_REGISTER_gethostbyname_items
#ifdef MF_REGISTER_gethostbyname_items
      __mf_register (p->h_aliases, nreg, MF_REGISTER_gethostbyname_items,
      __mf_register (p->h_aliases, nreg, MF_REGISTER_gethostbyname_items,
        "gethostbyname result->h_aliases");
        "gethostbyname result->h_aliases");
#endif
#endif
      MF_VALIDATE_EXTENT (p->h_aliases, nreg, __MF_CHECK_WRITE,
      MF_VALIDATE_EXTENT (p->h_aliases, nreg, __MF_CHECK_WRITE,
        "gethostbyname result->h_aliases");
        "gethostbyname result->h_aliases");
    }
    }
 
 
    if (NULL != (ss = p->h_addr_list)) {
    if (NULL != (ss = p->h_addr_list)) {
      for (nreg = 1;; ++nreg) {
      for (nreg = 1;; ++nreg) {
        s = *ss++;
        s = *ss++;
        if (NULL == s)
        if (NULL == s)
          break;
          break;
#ifdef MF_REGISTER_gethostbyname_items
#ifdef MF_REGISTER_gethostbyname_items
        __mf_register (s, p->h_length, MF_REGISTER_gethostbyname_items,
        __mf_register (s, p->h_length, MF_REGISTER_gethostbyname_items,
          "gethostbyname result->h_addr_list[]");
          "gethostbyname result->h_addr_list[]");
#endif
#endif
        MF_VALIDATE_EXTENT (s, p->h_length, __MF_CHECK_WRITE,
        MF_VALIDATE_EXTENT (s, p->h_length, __MF_CHECK_WRITE,
          "gethostbyname result->h_addr_list[]");
          "gethostbyname result->h_addr_list[]");
      }
      }
      nreg *= sizeof (*p->h_addr_list);
      nreg *= sizeof (*p->h_addr_list);
#ifdef MF_REGISTER_gethostbyname_items
#ifdef MF_REGISTER_gethostbyname_items
      __mf_register (p->h_addr_list, nreg, MF_REGISTER_gethostbyname_items,
      __mf_register (p->h_addr_list, nreg, MF_REGISTER_gethostbyname_items,
        "gethostbyname result->h_addr_list");
        "gethostbyname result->h_addr_list");
#endif
#endif
      MF_VALIDATE_EXTENT (p->h_addr_list, nreg, __MF_CHECK_WRITE,
      MF_VALIDATE_EXTENT (p->h_addr_list, nreg, __MF_CHECK_WRITE,
        "gethostbyname result->h_addr_list");
        "gethostbyname result->h_addr_list");
    }
    }
  }
  }
  return p;
  return p;
}
}
 
 
#endif /* HAVE_NETDB_H */
#endif /* HAVE_NETDB_H */
 
 
 
 
#ifdef HAVE_SYS_WAIT_H
#ifdef HAVE_SYS_WAIT_H
 
 
WRAPPER2(pid_t, wait, int *status)
WRAPPER2(pid_t, wait, int *status)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  if (NULL != status)
  if (NULL != status)
    MF_VALIDATE_EXTENT (status, sizeof (*status), __MF_CHECK_WRITE,
    MF_VALIDATE_EXTENT (status, sizeof (*status), __MF_CHECK_WRITE,
      "wait status");
      "wait status");
  return wait (status);
  return wait (status);
}
}
 
 
 
 
WRAPPER2(pid_t, waitpid, pid_t pid, int *status, int options)
WRAPPER2(pid_t, waitpid, pid_t pid, int *status, int options)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  if (NULL != status)
  if (NULL != status)
    MF_VALIDATE_EXTENT (status, sizeof (*status), __MF_CHECK_WRITE,
    MF_VALIDATE_EXTENT (status, sizeof (*status), __MF_CHECK_WRITE,
      "waitpid status");
      "waitpid status");
  return waitpid (pid, status, options);
  return waitpid (pid, status, options);
}
}
 
 
#endif /* HAVE_SYS_WAIT_H */
#endif /* HAVE_SYS_WAIT_H */
 
 
 
 
WRAPPER2(FILE *, popen, const char *command, const char *mode)
WRAPPER2(FILE *, popen, const char *command, const char *mode)
{
{
  size_t n;
  size_t n;
  FILE *p;
  FILE *p;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
 
 
  n = strlen (command);
  n = strlen (command);
  MF_VALIDATE_EXTENT (command, CLAMPADD(n, 1), __MF_CHECK_READ, "popen path");
  MF_VALIDATE_EXTENT (command, CLAMPADD(n, 1), __MF_CHECK_READ, "popen path");
 
 
  n = strlen (mode);
  n = strlen (mode);
  MF_VALIDATE_EXTENT (mode, CLAMPADD(n, 1), __MF_CHECK_READ, "popen mode");
  MF_VALIDATE_EXTENT (mode, CLAMPADD(n, 1), __MF_CHECK_READ, "popen mode");
 
 
  p = popen (command, mode);
  p = popen (command, mode);
  if (NULL != p) {
  if (NULL != p) {
#ifdef MF_REGISTER_fopen
#ifdef MF_REGISTER_fopen
    __mf_register (p, sizeof (*p), MF_REGISTER_fopen, "popen result");
    __mf_register (p, sizeof (*p), MF_REGISTER_fopen, "popen result");
#endif
#endif
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "popen result");
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_WRITE, "popen result");
  }
  }
  return p;
  return p;
}
}
 
 
 
 
WRAPPER2(int, pclose, FILE *stream)
WRAPPER2(int, pclose, FILE *stream)
{
{
  int resp;
  int resp;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (stream, sizeof (*stream), __MF_CHECK_WRITE,
    "pclose stream");
    "pclose stream");
  resp = pclose (stream);
  resp = pclose (stream);
#ifdef MF_REGISTER_fopen
#ifdef MF_REGISTER_fopen
  __mf_unregister (stream, sizeof (*stream), MF_REGISTER_fopen);
  __mf_unregister (stream, sizeof (*stream), MF_REGISTER_fopen);
#endif
#endif
  return resp;
  return resp;
}
}
 
 
 
 
WRAPPER2(int, execve, const char *path, char *const argv [],
WRAPPER2(int, execve, const char *path, char *const argv [],
        char *const envp[])
        char *const envp[])
{
{
  size_t n;
  size_t n;
  char *const *p;
  char *const *p;
  const char *s;
  const char *s;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
 
 
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "execve path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "execve path");
 
 
  for (p = argv;;) {
  for (p = argv;;) {
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_READ, "execve *argv");
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_READ, "execve *argv");
    s = *p++;
    s = *p++;
    if (NULL == s)
    if (NULL == s)
      break;
      break;
    n = strlen (s);
    n = strlen (s);
    MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_READ, "execve **argv");
    MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_READ, "execve **argv");
  }
  }
 
 
  for (p = envp;;) {
  for (p = envp;;) {
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_READ, "execve *envp");
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_READ, "execve *envp");
    s = *p++;
    s = *p++;
    if (NULL == s)
    if (NULL == s)
      break;
      break;
    n = strlen (s);
    n = strlen (s);
    MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_READ, "execve **envp");
    MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_READ, "execve **envp");
  }
  }
  return execve (path, argv, envp);
  return execve (path, argv, envp);
}
}
 
 
 
 
WRAPPER2(int, execv, const char *path, char *const argv [])
WRAPPER2(int, execv, const char *path, char *const argv [])
{
{
  size_t n;
  size_t n;
  char *const *p;
  char *const *p;
  const char *s;
  const char *s;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
 
 
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "execv path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "execv path");
 
 
  for (p = argv;;) {
  for (p = argv;;) {
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_READ, "execv *argv");
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_READ, "execv *argv");
    s = *p++;
    s = *p++;
    if (NULL == s)
    if (NULL == s)
      break;
      break;
    n = strlen (s);
    n = strlen (s);
    MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_READ, "execv **argv");
    MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_READ, "execv **argv");
  }
  }
  return execv (path, argv);
  return execv (path, argv);
}
}
 
 
 
 
WRAPPER2(int, execvp, const char *path, char *const argv [])
WRAPPER2(int, execvp, const char *path, char *const argv [])
{
{
  size_t n;
  size_t n;
  char *const *p;
  char *const *p;
  const char *s;
  const char *s;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
 
 
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "execvp path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "execvp path");
 
 
  for (p = argv;;) {
  for (p = argv;;) {
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_READ, "execvp *argv");
    MF_VALIDATE_EXTENT (p, sizeof (*p), __MF_CHECK_READ, "execvp *argv");
    s = *p++;
    s = *p++;
    if (NULL == s)
    if (NULL == s)
      break;
      break;
    n = strlen (s);
    n = strlen (s);
    MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_READ, "execvp **argv");
    MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_READ, "execvp **argv");
  }
  }
  return execvp (path, argv);
  return execvp (path, argv);
}
}
 
 
 
 
WRAPPER2(int, system, const char *string)
WRAPPER2(int, system, const char *string)
{
{
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (string);
  n = strlen (string);
  MF_VALIDATE_EXTENT (string, CLAMPADD(n, 1), __MF_CHECK_READ,
  MF_VALIDATE_EXTENT (string, CLAMPADD(n, 1), __MF_CHECK_READ,
    "system string");
    "system string");
  return system (string);
  return system (string);
}
}
 
 
 
 
WRAPPER2(void *, dlopen, const char *path, int flags)
WRAPPER2(void *, dlopen, const char *path, int flags)
{
{
  void *p;
  void *p;
  size_t n;
  size_t n;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  n = strlen (path);
  n = strlen (path);
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "dlopen path");
  MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "dlopen path");
  p = dlopen (path, flags);
  p = dlopen (path, flags);
  if (NULL != p) {
  if (NULL != p) {
#ifdef MF_REGISTER_dlopen
#ifdef MF_REGISTER_dlopen
    __mf_register (p, 0, MF_REGISTER_dlopen, "dlopen result");
    __mf_register (p, 0, MF_REGISTER_dlopen, "dlopen result");
#endif
#endif
    MF_VALIDATE_EXTENT (p, 0, __MF_CHECK_WRITE, "dlopen result");
    MF_VALIDATE_EXTENT (p, 0, __MF_CHECK_WRITE, "dlopen result");
  }
  }
  return p;
  return p;
}
}
 
 
 
 
WRAPPER2(int, dlclose, void *handle)
WRAPPER2(int, dlclose, void *handle)
{
{
  int resp;
  int resp;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (handle, 0, __MF_CHECK_READ, "dlclose handle");
  MF_VALIDATE_EXTENT (handle, 0, __MF_CHECK_READ, "dlclose handle");
  resp = dlclose (handle);
  resp = dlclose (handle);
#ifdef MF_REGISTER_dlopen
#ifdef MF_REGISTER_dlopen
  __mf_unregister (handle, 0, MF_REGISTER_dlopen);
  __mf_unregister (handle, 0, MF_REGISTER_dlopen);
#endif
#endif
  return resp;
  return resp;
}
}
 
 
 
 
WRAPPER2(char *, dlerror)
WRAPPER2(char *, dlerror)
{
{
  char *p;
  char *p;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  p = dlerror ();
  p = dlerror ();
  if (NULL != p) {
  if (NULL != p) {
    size_t n;
    size_t n;
    n = strlen (p);
    n = strlen (p);
    n = CLAMPADD(n, 1);
    n = CLAMPADD(n, 1);
#ifdef MF_REGISTER_dlerror
#ifdef MF_REGISTER_dlerror
    __mf_register (p, n, MF_REGISTER_dlerror, "dlerror result");
    __mf_register (p, n, MF_REGISTER_dlerror, "dlerror result");
#endif
#endif
    MF_VALIDATE_EXTENT (p, n, __MF_CHECK_WRITE, "dlerror result");
    MF_VALIDATE_EXTENT (p, n, __MF_CHECK_WRITE, "dlerror result");
  }
  }
  return p;
  return p;
}
}
 
 
 
 
WRAPPER2(void *, dlsym, void *handle, char *symbol)
WRAPPER2(void *, dlsym, void *handle, char *symbol)
{
{
  size_t n;
  size_t n;
  void *p;
  void *p;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (handle, 0, __MF_CHECK_READ, "dlsym handle");
  MF_VALIDATE_EXTENT (handle, 0, __MF_CHECK_READ, "dlsym handle");
  n = strlen (symbol);
  n = strlen (symbol);
  MF_VALIDATE_EXTENT (symbol, CLAMPADD(n, 1), __MF_CHECK_READ, "dlsym symbol");
  MF_VALIDATE_EXTENT (symbol, CLAMPADD(n, 1), __MF_CHECK_READ, "dlsym symbol");
  p = dlsym (handle, symbol);
  p = dlsym (handle, symbol);
  if (NULL != p) {
  if (NULL != p) {
#ifdef MF_REGISTER_dlsym
#ifdef MF_REGISTER_dlsym
    __mf_register (p, 0, MF_REGISTER_dlsym, "dlsym result");
    __mf_register (p, 0, MF_REGISTER_dlsym, "dlsym result");
#endif
#endif
    MF_VALIDATE_EXTENT (p, 0, __MF_CHECK_WRITE, "dlsym result");
    MF_VALIDATE_EXTENT (p, 0, __MF_CHECK_WRITE, "dlsym result");
  }
  }
  return p;
  return p;
}
}
 
 
 
 
#if defined (HAVE_SYS_IPC_H) && defined (HAVE_SYS_SEM_H) && defined (HAVE_SYS_SHM_H)
#if defined (HAVE_SYS_IPC_H) && defined (HAVE_SYS_SEM_H) && defined (HAVE_SYS_SHM_H)
 
 
WRAPPER2(int, semop, int semid, struct sembuf *sops, unsigned nsops)
WRAPPER2(int, semop, int semid, struct sembuf *sops, unsigned nsops)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  MF_VALIDATE_EXTENT (sops, sizeof (*sops) * nsops, __MF_CHECK_READ,
  MF_VALIDATE_EXTENT (sops, sizeof (*sops) * nsops, __MF_CHECK_READ,
    "semop sops");
    "semop sops");
  return semop (semid, sops, nsops);
  return semop (semid, sops, nsops);
}
}
 
 
 
 
#ifndef HAVE_UNION_SEMUN
#ifndef HAVE_UNION_SEMUN
union semun {
union semun {
        int val;                        /* value for SETVAL */
        int val;                        /* value for SETVAL */
        struct semid_ds *buf;           /* buffer for IPC_STAT, IPC_SET */
        struct semid_ds *buf;           /* buffer for IPC_STAT, IPC_SET */
        unsigned short int *array;      /* array for GETALL, SETALL */
        unsigned short int *array;      /* array for GETALL, SETALL */
        struct seminfo *__buf;          /* buffer for IPC_INFO */
        struct seminfo *__buf;          /* buffer for IPC_INFO */
};
};
#endif
#endif
WRAPPER2(int, semctl, int semid, int semnum, int cmd, union semun arg)
WRAPPER2(int, semctl, int semid, int semnum, int cmd, union semun arg)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  switch (cmd) {
  switch (cmd) {
  case IPC_STAT:
  case IPC_STAT:
    MF_VALIDATE_EXTENT (arg.buf, sizeof (*arg.buf), __MF_CHECK_WRITE,
    MF_VALIDATE_EXTENT (arg.buf, sizeof (*arg.buf), __MF_CHECK_WRITE,
      "semctl buf");
      "semctl buf");
    break;
    break;
  case IPC_SET:
  case IPC_SET:
    MF_VALIDATE_EXTENT (arg.buf, sizeof (*arg.buf), __MF_CHECK_READ,
    MF_VALIDATE_EXTENT (arg.buf, sizeof (*arg.buf), __MF_CHECK_READ,
      "semctl buf");
      "semctl buf");
    break;
    break;
  case GETALL:
  case GETALL:
    MF_VALIDATE_EXTENT (arg.array, sizeof (*arg.array), __MF_CHECK_WRITE,
    MF_VALIDATE_EXTENT (arg.array, sizeof (*arg.array), __MF_CHECK_WRITE,
      "semctl array");
      "semctl array");
  case SETALL:
  case SETALL:
    MF_VALIDATE_EXTENT (arg.array, sizeof (*arg.array), __MF_CHECK_READ,
    MF_VALIDATE_EXTENT (arg.array, sizeof (*arg.array), __MF_CHECK_READ,
      "semctl array");
      "semctl array");
    break;
    break;
#ifdef IPC_INFO
#ifdef IPC_INFO
  /* FreeBSD 5.1 And Cygwin headers include IPC_INFO but not the __buf field.  */
  /* FreeBSD 5.1 And Cygwin headers include IPC_INFO but not the __buf field.  */
#if !defined(__FreeBSD__) && !defined(__CYGWIN__)
#if !defined(__FreeBSD__) && !defined(__CYGWIN__)
  case IPC_INFO:
  case IPC_INFO:
    MF_VALIDATE_EXTENT (arg.__buf, sizeof (*arg.__buf), __MF_CHECK_WRITE,
    MF_VALIDATE_EXTENT (arg.__buf, sizeof (*arg.__buf), __MF_CHECK_WRITE,
      "semctl __buf");
      "semctl __buf");
    break;
    break;
#endif
#endif
#endif
#endif
  default:
  default:
    break;
    break;
  }
  }
  return semctl (semid, semnum, cmd, arg);
  return semctl (semid, semnum, cmd, arg);
}
}
 
 
 
 
WRAPPER2(int, shmctl, int shmid, int cmd, struct shmid_ds *buf)
WRAPPER2(int, shmctl, int shmid, int cmd, struct shmid_ds *buf)
{
{
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  switch (cmd) {
  switch (cmd) {
  case IPC_STAT:
  case IPC_STAT:
    MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_WRITE,
    MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_WRITE,
      "shmctl buf");
      "shmctl buf");
    break;
    break;
  case IPC_SET:
  case IPC_SET:
    MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_READ,
    MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_READ,
      "shmctl buf");
      "shmctl buf");
    break;
    break;
  default:
  default:
    break;
    break;
  }
  }
  return shmctl (shmid, cmd, buf);
  return shmctl (shmid, cmd, buf);
}
}
 
 
 
 
WRAPPER2(void *, shmat, int shmid, const void *shmaddr, int shmflg)
WRAPPER2(void *, shmat, int shmid, const void *shmaddr, int shmflg)
{
{
  void *p;
  void *p;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  p = shmat (shmid, shmaddr, shmflg);
  p = shmat (shmid, shmaddr, shmflg);
#ifdef MF_REGISTER_shmat
#ifdef MF_REGISTER_shmat
  if (NULL != p) {
  if (NULL != p) {
    struct shmid_ds buf;
    struct shmid_ds buf;
    __mf_register (p, shmctl (shmid, IPC_STAT, &buf) ? 0 : buf.shm_segsz,
    __mf_register (p, shmctl (shmid, IPC_STAT, &buf) ? 0 : buf.shm_segsz,
      MF_REGISTER_shmat, "shmat result");
      MF_REGISTER_shmat, "shmat result");
  }
  }
#endif
#endif
  return p;
  return p;
}
}
 
 
 
 
WRAPPER2(int, shmdt, const void *shmaddr)
WRAPPER2(int, shmdt, const void *shmaddr)
{
{
  int resp;
  int resp;
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  TRACE ("%s\n", __PRETTY_FUNCTION__);
  resp = shmdt (shmaddr);
  resp = shmdt (shmaddr);
#ifdef MF_REGISTER_shmat
#ifdef MF_REGISTER_shmat
  __mf_unregister ((void *)shmaddr, 0, MF_REGISTER_shmat);
  __mf_unregister ((void *)shmaddr, 0, MF_REGISTER_shmat);
#endif
#endif
  return resp;
  return resp;
}
}
 
 
 
 
#endif /* HAVE_SYS_IPC/SEM/SHM_H */
#endif /* HAVE_SYS_IPC/SEM/SHM_H */
 
 
 
 
 
 
/* ctype stuff.  This is host-specific by necessity, as the arrays
/* ctype stuff.  This is host-specific by necessity, as the arrays
   that is used by most is*()/to*() macros are implementation-defined.  */
   that is used by most is*()/to*() macros are implementation-defined.  */
 
 
/* GLIBC 2.3 */
/* GLIBC 2.3 */
#ifdef HAVE___CTYPE_B_LOC
#ifdef HAVE___CTYPE_B_LOC
WRAPPER2(unsigned short **, __ctype_b_loc, void)
WRAPPER2(unsigned short **, __ctype_b_loc, void)
{
{
  static unsigned short * last_buf = (void *) 0;
  static unsigned short * last_buf = (void *) 0;
  static unsigned short ** last_ptr = (void *) 0;
  static unsigned short ** last_ptr = (void *) 0;
  unsigned short ** ptr = (unsigned short **) __ctype_b_loc ();
  unsigned short ** ptr = (unsigned short **) __ctype_b_loc ();
  unsigned short * buf = * ptr;
  unsigned short * buf = * ptr;
  if (ptr != last_ptr)
  if (ptr != last_ptr)
    {
    {
      /* XXX: unregister last_ptr? */
      /* XXX: unregister last_ptr? */
      last_ptr = ptr;
      last_ptr = ptr;
      __mf_register (last_ptr, sizeof(last_ptr), __MF_TYPE_STATIC, "ctype_b_loc **");
      __mf_register (last_ptr, sizeof(last_ptr), __MF_TYPE_STATIC, "ctype_b_loc **");
    }
    }
  if (buf != last_buf)
  if (buf != last_buf)
    {
    {
      last_buf = buf;
      last_buf = buf;
      __mf_register ((void *) (last_buf - 128), 384 * sizeof(unsigned short), __MF_TYPE_STATIC,
      __mf_register ((void *) (last_buf - 128), 384 * sizeof(unsigned short), __MF_TYPE_STATIC,
                     "ctype_b_loc []");
                     "ctype_b_loc []");
    }
    }
  return ptr;
  return ptr;
}
}
#endif
#endif
 
 
#ifdef HAVE___CTYPE_TOUPPER_LOC
#ifdef HAVE___CTYPE_TOUPPER_LOC
WRAPPER2(int **, __ctype_toupper_loc, void)
WRAPPER2(int **, __ctype_toupper_loc, void)
{
{
  static int * last_buf = (void *) 0;
  static int * last_buf = (void *) 0;
  static int ** last_ptr = (void *) 0;
  static int ** last_ptr = (void *) 0;
  int ** ptr = (int **) __ctype_toupper_loc ();
  int ** ptr = (int **) __ctype_toupper_loc ();
  int * buf = * ptr;
  int * buf = * ptr;
  if (ptr != last_ptr)
  if (ptr != last_ptr)
    {
    {
      /* XXX: unregister last_ptr? */
      /* XXX: unregister last_ptr? */
      last_ptr = ptr;
      last_ptr = ptr;
      __mf_register (last_ptr, sizeof(last_ptr), __MF_TYPE_STATIC, "ctype_toupper_loc **");
      __mf_register (last_ptr, sizeof(last_ptr), __MF_TYPE_STATIC, "ctype_toupper_loc **");
    }
    }
  if (buf != last_buf)
  if (buf != last_buf)
    {
    {
      last_buf = buf;
      last_buf = buf;
      __mf_register ((void *) (last_buf - 128), 384 * sizeof(int), __MF_TYPE_STATIC,
      __mf_register ((void *) (last_buf - 128), 384 * sizeof(int), __MF_TYPE_STATIC,
                     "ctype_toupper_loc []");
                     "ctype_toupper_loc []");
    }
    }
  return ptr;
  return ptr;
}
}
#endif
#endif
 
 
#ifdef HAVE___CTYPE_TOLOWER_LOC
#ifdef HAVE___CTYPE_TOLOWER_LOC
WRAPPER2(int **, __ctype_tolower_loc, void)
WRAPPER2(int **, __ctype_tolower_loc, void)
{
{
  static int * last_buf = (void *) 0;
  static int * last_buf = (void *) 0;
  static int ** last_ptr = (void *) 0;
  static int ** last_ptr = (void *) 0;
  int ** ptr = (int **) __ctype_tolower_loc ();
  int ** ptr = (int **) __ctype_tolower_loc ();
  int * buf = * ptr;
  int * buf = * ptr;
  if (ptr != last_ptr)
  if (ptr != last_ptr)
    {
    {
      /* XXX: unregister last_ptr? */
      /* XXX: unregister last_ptr? */
      last_ptr = ptr;
      last_ptr = ptr;
      __mf_register (last_ptr, sizeof(last_ptr), __MF_TYPE_STATIC, "ctype_tolower_loc **");
      __mf_register (last_ptr, sizeof(last_ptr), __MF_TYPE_STATIC, "ctype_tolower_loc **");
    }
    }
  if (buf != last_buf)
  if (buf != last_buf)
    {
    {
      last_buf = buf;
      last_buf = buf;
      __mf_register ((void *) (last_buf - 128), 384 * sizeof(int), __MF_TYPE_STATIC,
      __mf_register ((void *) (last_buf - 128), 384 * sizeof(int), __MF_TYPE_STATIC,
                     "ctype_tolower_loc []");
                     "ctype_tolower_loc []");
    }
    }
  return ptr;
  return ptr;
}
}
#endif
#endif
 
 
 
 
/* passwd/group related functions.  These register every (static) pointer value returned,
/* passwd/group related functions.  These register every (static) pointer value returned,
   and rely on libmudflap's quiet toleration of duplicate static registrations.  */
   and rely on libmudflap's quiet toleration of duplicate static registrations.  */
 
 
#ifdef HAVE_GETLOGIN
#ifdef HAVE_GETLOGIN
WRAPPER2(char *, getlogin, void)
WRAPPER2(char *, getlogin, void)
{
{
  char *buf = getlogin ();
  char *buf = getlogin ();
  if (buf != NULL)
  if (buf != NULL)
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
                   "getlogin() return");
                   "getlogin() return");
  return buf;
  return buf;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_CUSERID
#ifdef HAVE_CUSERID
WRAPPER2(char *, cuserid, char * buf)
WRAPPER2(char *, cuserid, char * buf)
{
{
  if (buf != NULL)
  if (buf != NULL)
    {
    {
      MF_VALIDATE_EXTENT(buf, L_cuserid, __MF_CHECK_WRITE,
      MF_VALIDATE_EXTENT(buf, L_cuserid, __MF_CHECK_WRITE,
                         "cuserid destination");
                         "cuserid destination");
      return cuserid (buf);
      return cuserid (buf);
    }
    }
  buf = cuserid (NULL);
  buf = cuserid (NULL);
  if (buf != NULL)
  if (buf != NULL)
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
                   "getcuserid() return");
                   "getcuserid() return");
  return buf;
  return buf;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_GETPWNAM
#ifdef HAVE_GETPWNAM
WRAPPER2(struct passwd *, getpwnam, const char *name)
WRAPPER2(struct passwd *, getpwnam, const char *name)
{
{
  struct passwd *buf;
  struct passwd *buf;
  MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ,
  MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ,
                     "getpwnam name");
                     "getpwnam name");
  buf = getpwnam (name);
  buf = getpwnam (name);
  if (buf != NULL)
  if (buf != NULL)
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
                   "getpw*() return");
                   "getpw*() return");
  return buf;
  return buf;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_GETPWUID
#ifdef HAVE_GETPWUID
WRAPPER2(struct passwd *, getpwuid, uid_t uid)
WRAPPER2(struct passwd *, getpwuid, uid_t uid)
{
{
  struct passwd *buf;
  struct passwd *buf;
  buf = getpwuid (uid);
  buf = getpwuid (uid);
  if (buf != NULL)
  if (buf != NULL)
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
                   "getpw*() return");
                   "getpw*() return");
  return buf;
  return buf;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_GETGRNAM
#ifdef HAVE_GETGRNAM
WRAPPER2(struct group *, getgrnam, const char *name)
WRAPPER2(struct group *, getgrnam, const char *name)
{
{
  struct group *buf;
  struct group *buf;
  MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ,
  MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ,
                     "getgrnam name");
                     "getgrnam name");
  buf = getgrnam (name);
  buf = getgrnam (name);
  if (buf != NULL)
  if (buf != NULL)
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
                   "getgr*() return");
                   "getgr*() return");
  return buf;
  return buf;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_GETGRGID
#ifdef HAVE_GETGRGID
WRAPPER2(struct group *, getgrgid, uid_t uid)
WRAPPER2(struct group *, getgrgid, uid_t uid)
{
{
  struct group *buf;
  struct group *buf;
  buf = getgrgid (uid);
  buf = getgrgid (uid);
  if (buf != NULL)
  if (buf != NULL)
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
                   "getgr*() return");
                   "getgr*() return");
  return buf;
  return buf;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_GETSERVENT
#ifdef HAVE_GETSERVENT
WRAPPER2(struct servent *, getservent, void)
WRAPPER2(struct servent *, getservent, void)
{
{
  struct servent *buf;
  struct servent *buf;
  buf = getservent ();
  buf = getservent ();
  if (buf != NULL)
  if (buf != NULL)
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
                   "getserv*() return");
                   "getserv*() return");
  return buf;
  return buf;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_GETSERVBYNAME
#ifdef HAVE_GETSERVBYNAME
WRAPPER2(struct servent *, getservbyname, const char *name, const char *proto)
WRAPPER2(struct servent *, getservbyname, const char *name, const char *proto)
{
{
  struct servent *buf;
  struct servent *buf;
  MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ,
  MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ,
                     "getservbyname name");
                     "getservbyname name");
  MF_VALIDATE_EXTENT(proto, strlen(proto)+1, __MF_CHECK_READ,
  MF_VALIDATE_EXTENT(proto, strlen(proto)+1, __MF_CHECK_READ,
                     "getservbyname proto");
                     "getservbyname proto");
  buf = getservbyname (name, proto);
  buf = getservbyname (name, proto);
  if (buf != NULL)
  if (buf != NULL)
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
                   "getserv*() return");
                   "getserv*() return");
  return buf;
  return buf;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_GETSERVBYPORT
#ifdef HAVE_GETSERVBYPORT
WRAPPER2(struct servent *, getservbyport, int port, const char *proto)
WRAPPER2(struct servent *, getservbyport, int port, const char *proto)
{
{
  struct servent *buf;
  struct servent *buf;
  MF_VALIDATE_EXTENT(proto, strlen(proto)+1, __MF_CHECK_READ,
  MF_VALIDATE_EXTENT(proto, strlen(proto)+1, __MF_CHECK_READ,
                     "getservbyport proto");
                     "getservbyport proto");
  buf = getservbyport (port, proto);
  buf = getservbyport (port, proto);
  if (buf != NULL)
  if (buf != NULL)
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
                   "getserv*() return");
                   "getserv*() return");
  return buf;
  return buf;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_GAI_STRERROR
#ifdef HAVE_GAI_STRERROR
WRAPPER2(const char *, gai_strerror, int errcode)
WRAPPER2(const char *, gai_strerror, int errcode)
{
{
  const char *buf;
  const char *buf;
  buf = gai_strerror (errcode);
  buf = gai_strerror (errcode);
  if (buf != NULL)
  if (buf != NULL)
    __mf_register ((void *) buf, strlen(buf)+1, __MF_TYPE_STATIC,
    __mf_register ((void *) buf, strlen(buf)+1, __MF_TYPE_STATIC,
                   "gai_strerror() return");
                   "gai_strerror() return");
  return buf;
  return buf;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_GETMNTENT
#ifdef HAVE_GETMNTENT
WRAPPER2(struct mntent *, getmntent, FILE *filep)
WRAPPER2(struct mntent *, getmntent, FILE *filep)
{
{
  struct mntent *m;
  struct mntent *m;
  static struct mntent *last = NULL;
  static struct mntent *last = NULL;
 
 
  MF_VALIDATE_EXTENT (filep, sizeof (*filep), __MF_CHECK_WRITE,
  MF_VALIDATE_EXTENT (filep, sizeof (*filep), __MF_CHECK_WRITE,
    "getmntent stream");
    "getmntent stream");
#define UR(field) __mf_unregister(last->field, strlen (last->field)+1, __MF_TYPE_STATIC)
#define UR(field) __mf_unregister(last->field, strlen (last->field)+1, __MF_TYPE_STATIC)
  if (last)
  if (last)
    {
    {
      UR (mnt_fsname);
      UR (mnt_fsname);
      UR (mnt_dir);
      UR (mnt_dir);
      UR (mnt_type);
      UR (mnt_type);
      UR (mnt_opts);
      UR (mnt_opts);
      __mf_unregister (last, sizeof (*last), __MF_TYPE_STATIC);
      __mf_unregister (last, sizeof (*last), __MF_TYPE_STATIC);
    }
    }
#undef UR
#undef UR
 
 
  m = getmntent (filep);
  m = getmntent (filep);
  last = m;
  last = m;
 
 
#define R(field) __mf_register(last->field, strlen (last->field)+1, __MF_TYPE_STATIC, "mntent " #field)
#define R(field) __mf_register(last->field, strlen (last->field)+1, __MF_TYPE_STATIC, "mntent " #field)
  if (m)
  if (m)
    {
    {
      R (mnt_fsname);
      R (mnt_fsname);
      R (mnt_dir);
      R (mnt_dir);
      R (mnt_type);
      R (mnt_type);
      R (mnt_opts);
      R (mnt_opts);
      __mf_register (last, sizeof (*last), __MF_TYPE_STATIC, "getmntent result");
      __mf_register (last, sizeof (*last), __MF_TYPE_STATIC, "getmntent result");
    }
    }
#undef R
#undef R
 
 
  return m;
  return m;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_INET_NTOA
#ifdef HAVE_INET_NTOA
WRAPPER2(char *, inet_ntoa, struct in_addr in)
WRAPPER2(char *, inet_ntoa, struct in_addr in)
{
{
  static char *last_buf = NULL;
  static char *last_buf = NULL;
  char *buf;
  char *buf;
  if (last_buf)
  if (last_buf)
    __mf_unregister (last_buf, strlen (last_buf)+1, __MF_TYPE_STATIC);
    __mf_unregister (last_buf, strlen (last_buf)+1, __MF_TYPE_STATIC);
  buf = inet_ntoa (in);
  buf = inet_ntoa (in);
  last_buf = buf;
  last_buf = buf;
  if (buf)
  if (buf)
    __mf_register (last_buf, strlen (last_buf)+1, __MF_TYPE_STATIC, "inet_ntoa result");
    __mf_register (last_buf, strlen (last_buf)+1, __MF_TYPE_STATIC, "inet_ntoa result");
  return buf;
  return buf;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_GETPROTOENT
#ifdef HAVE_GETPROTOENT
WRAPPER2(struct protoent *, getprotoent, void)
WRAPPER2(struct protoent *, getprotoent, void)
{
{
  struct protoent *buf;
  struct protoent *buf;
  buf = getprotoent ();
  buf = getprotoent ();
  if (buf != NULL)
  if (buf != NULL)
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC, "getproto*() return");
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC, "getproto*() return");
  return buf;
  return buf;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_GETPROTOBYNAME
#ifdef HAVE_GETPROTOBYNAME
WRAPPER2(struct protoent *, getprotobyname, const char *name)
WRAPPER2(struct protoent *, getprotobyname, const char *name)
{
{
  struct protoent *buf;
  struct protoent *buf;
  MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ,
  MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ,
                     "getprotobyname name");
                     "getprotobyname name");
  buf = getprotobyname (name);
  buf = getprotobyname (name);
  if (buf != NULL)
  if (buf != NULL)
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
                   "getproto*() return");
                   "getproto*() return");
  return buf;
  return buf;
}
}
#endif
#endif
 
 
 
 
#ifdef HAVE_GETPROTOBYNUMBER
#ifdef HAVE_GETPROTOBYNUMBER
WRAPPER2(struct protoent *, getprotobynumber, int port)
WRAPPER2(struct protoent *, getprotobynumber, int port)
{
{
  struct protoent *buf;
  struct protoent *buf;
  buf = getprotobynumber (port);
  buf = getprotobynumber (port);
  if (buf != NULL)
  if (buf != NULL)
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
    __mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
                   "getproto*() return");
                   "getproto*() return");
  return buf;
  return buf;
}
}
#endif
#endif
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.