Changeset 1679 for zzuf


Ignore:
Timestamp:
Jan 16, 2007, 3:36:33 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Got rid of the *_load() functions. Now each diverted function is supposed to check that the *_orig() functions it calls are properly loaded.
Location:
zzuf/trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/libzzuf.c

    r1672 r1679  
    3737#include "libzzuf.h"
    3838#include "debug.h"
    39 #include "load.h"
    4039#include "fd.h"
    4140#include "fuzz.h"
     
    5352{
    5453    char *tmp, *tmp2;
    55 
    56     _zz_load_mem();
    57     _zz_load_signal();
    58     _zz_load_fd();
    59     _zz_load_stream();
    6054
    6155    tmp = getenv("ZZUF_DEBUG");
  • zzuf/trunk/src/load-fd.c

    r1678 r1679  
    7070#endif
    7171static int     (*close_orig)   (int fd);
    72 
    73 
    74 void _zz_load_fd(void)
    75 {
    76     LOADSYM(open);
    77 #ifdef HAVE_OPEN64
    78     LOADSYM(open64);
    79 #endif
    80     LOADSYM(accept);
    81     LOADSYM(socket);
    82     LOADSYM(read);
    83     LOADSYM(readv);
    84     LOADSYM(pread);
    85     LOADSYM(lseek);
    86 #ifdef HAVE_LSEEK64
    87     LOADSYM(lseek64);
    88 #endif
    89     LOADSYM(close);
    90 }
    9172
    9273#define OPEN(fn) \
     
    174155    /* Sanity check, can be OK though (for instance with a character device) */
    175156#ifdef HAVE_LSEEK64
    176     off64_t ret = lseek64_orig(fd, 0, SEEK_CUR);
     157    off64_t ret;
     158    LOADSYM(lseek64);
     159    ret = lseek64_orig(fd, 0, SEEK_CUR);
    177160#else
    178     off_t ret = lseek_orig(fd, 0, SEEK_CUR);
     161    off_t ret;
     162    LOADSYM(lseek);
     163    ret = lseek_orig(fd, 0, SEEK_CUR);
    179164#endif
    180165    if(ret != -1 && ret != _zz_getpos(fd))
     
    308293    int ret;
    309294
    310     LOADSYM(close);
    311 
    312295    /* Hey, it’s our debug channel! Silently pretend we closed it. */
    313296    if(fd == DEBUG_FILENO)
    314297        return 0;
    315298
     299    LOADSYM(close);
    316300    ret = close_orig(fd);
    317301    if(!_zz_ready || !_zz_iswatched(fd) || _zz_disabled)
  • zzuf/trunk/src/load-mem.c

    r1649 r1679  
    8282                                     vm_size_t numbytes);
    8383#endif
    84 
    85 void _zz_load_mem(void)
    86 {
    87     LOADSYM(calloc);
    88     LOADSYM(malloc);
    89     LOADSYM(free);
    90     LOADSYM(realloc);
    91     LOADSYM(valloc);
    92 #ifdef HAVE_MEMALIGN
    93     LOADSYM(memalign);
    94 #endif
    95 #ifdef HAVE_POSIX_MEMALIGN
    96     LOADSYM(posix_memalign);
    97 #endif
    98 
    99     LOADSYM(mmap);
    100 #ifdef HAVE_MMAP64
    101     LOADSYM(mmap64);
    102 #endif
    103     LOADSYM(munmap);
    104 #ifdef HAVE_MAP_FD
    105     LOADSYM(map_fd);
    106 #endif
    107 }
    10884
    10985/* We need a static memory buffer because some functions call memory
  • zzuf/trunk/src/load-signal.c

    r1648 r1679  
    5252/* Local functions */
    5353static int isfatal(int signum);
    54 
    55 void _zz_load_signal(void)
    56 {
    57     LOADSYM(signal);
    58     LOADSYM(sigaction);
    59 }
    6054
    6155static int isfatal(int signum)
  • zzuf/trunk/src/load-stream.c

    r1648 r1679  
    8888int            (*__srefill_orig) (FILE *fp);
    8989#endif
    90 
    91 
    92 void _zz_load_stream(void)
    93 {
    94     LOADSYM(fopen);
    95 #ifdef HAVE_FOPEN64
    96     LOADSYM(fopen64);
    97 #endif
    98     LOADSYM(freopen);
    99     LOADSYM(fseek);
    100 #ifdef HAVE_FSEEKO
    101     LOADSYM(fseeko);
    102 #endif
    103     LOADSYM(rewind);
    104     LOADSYM(fread);
    105     LOADSYM(getc);
    106     LOADSYM(fgetc);
    107 #ifdef HAVE__IO_GETC
    108     LOADSYM(_IO_getc);
    109 #endif
    110     LOADSYM(fgets);
    111     LOADSYM(ungetc);
    112     LOADSYM(fclose);
    113 #ifdef HAVE_GETLINE
    114     LOADSYM(getline);
    115 #endif
    116 #ifdef HAVE_GETDELIM
    117     LOADSYM(getdelim);
    118 #endif
    119 #ifdef HAVE___GETDELIM
    120     LOADSYM(__getdelim);
    121 #endif
    122 #ifdef HAVE_FGETLN
    123     LOADSYM(fgetln);
    124 #endif
    125 #ifdef HAVE___SREFILL
    126     LOADSYM(__srefill);
    127 #endif
    128 }
    12990
    13091/* Our function wrappers */
     
    356317
    357318    LOADSYM(fgets);
     319    LOADSYM(fgetc);
    358320    fd = fileno(stream);
    359321    if(!_zz_ready || !_zz_iswatched(fd))
     
    462424        int fd, finished = 0; \
    463425        LOADSYM(fn); \
     426        LOADSYM(getdelim); \
     427        LOADSYM(fgetc); \
    464428        fd = fileno(stream); \
    465429        if(!_zz_ready || !_zz_iswatched(fd)) \
     
    543507
    544508    LOADSYM(fgetln);
     509    LOADSYM(fgetc);
    545510    fd = fileno(stream);
    546511    if(!_zz_ready || !_zz_iswatched(fd))
  • zzuf/trunk/src/load.h

    r1648 r1679  
    2828    } while(0)
    2929
    30 extern void _zz_load_fd(void);
    31 extern void _zz_load_mem(void);
    32 extern void _zz_load_signal(void);
    33 extern void _zz_load_stream(void);
    34 
Note: See TracChangeset for help on using the changeset viewer.