Changeset 4676


Ignore:
Timestamp:
10/07/10 00:44:47 (3 years ago)
Author:
sam
Message:

Implement ReOpenFile? and fix a few Win32 compilation warnings.

Location:
zzuf/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/configure.ac

    r4661 r4676  
    5555AC_CHECK_FUNCS(__open64 __lseek64 __fopen64 __freopen64 __ftello64 __fseeko64 __fsetpos64) 
    5656AC_CHECK_FUNCS(__fgets_chk __fgets_unlocked_chk __fread_chk __fread_unlocked_chk __read_chk __recv_chk __recvfrom_chk) 
    57 AC_CHECK_FUNCS(CreateFileA CreateFileW ReadFile CloseHandle) 
     57AC_CHECK_FUNCS(CreateFileA CreateFileW ReOpenFile ReadFile CloseHandle) 
    5858 
    5959AC_CHECK_TYPES(sighandler_t, [], [], 
  • zzuf/trunk/msvc/config.h

    r4661 r4676  
    8080/* #undef HAVE_RECVMSG */ 
    8181/* #undef HAVE_REGEX_H */ 
     82#define HAVE_REOPENFILE 1 
    8283/* #undef HAVE_SETENV */ 
    8384/* #undef HAVE_SETRLIMIT */ 
  • zzuf/trunk/src/common/fd.c

    r4253 r4676  
    4646 
    4747/* File descriptor cherry picking */ 
    48 static int *list = NULL; 
    49 static int static_list[512]; 
     48static int64_t *list = NULL; 
     49static int64_t static_list[512]; 
    5050 
    5151/* File descriptor stuff. When program is launched, we use the static array of 
     
    398398        return 0; 
    399399 
    400     return files[fds[fd]].already_fuzzed + files[fds[fd]].already_pos 
    401                                          - files[fds[fd]].pos; 
     400    return (int)(files[fds[fd]].already_fuzzed + files[fds[fd]].already_pos 
     401                                               - files[fds[fd]].pos); 
    402402} 
    403403 
  • zzuf/trunk/src/common/fuzz.c

    r4253 r4676  
    4747 
    4848/* Per-offset byte protection */ 
    49 static int *ranges = NULL; 
    50 static int static_ranges[512]; 
     49static int64_t *ranges = NULL; 
     50static int64_t static_ranges[512]; 
    5151 
    5252/* Per-value byte protection */ 
  • zzuf/trunk/src/common/ranges.c

    r4253 r4676  
    3333 * the static array static_ranges is used. It is the caller's duty to call 
    3434 * free() if the returned value is not static_ranges. */ 
    35 int *_zz_allocrange(char const *list, int *static_ranges) 
     35int64_t *_zz_allocrange(char const *list, int64_t *static_ranges) 
    3636{ 
    3737    char const *parser; 
    38     int *ranges; 
     38    int64_t *ranges; 
    3939    unsigned int i, chunks; 
    4040 
     
    4545 
    4646    if(chunks >= 256) 
    47         ranges = malloc((chunks + 1) * 2 * sizeof(unsigned int)); 
     47        ranges = malloc((chunks + 1) * 2 * sizeof(int64_t)); 
    4848    else 
    4949        ranges = static_ranges; 
     
    7070} 
    7171 
    72 int _zz_isinrange(int value, int const *ranges) 
     72int _zz_isinrange(int64_t value, int64_t const *ranges) 
    7373{ 
    74     int const *r; 
     74    int64_t const *r; 
    7575 
    7676    if(!ranges) 
  • zzuf/trunk/src/common/ranges.h

    r4253 r4676  
    1515 */ 
    1616 
    17 int *_zz_allocrange(char const *, int *); 
    18 int _zz_isinrange(int, int const *); 
     17int64_t *_zz_allocrange(char const *, int64_t *); 
     18int _zz_isinrange(int64_t, int64_t const *); 
    1919 
  • zzuf/trunk/src/libzzuf/lib-win32.c

    r4673 r4676  
    2828#   include <windows.h> 
    2929#endif 
     30#if defined HAVE_IO_H 
     31#   include <io.h> 
     32#endif 
    3033 
    3134#include "common.h" 
     
    4649                                             LPSECURITY_ATTRIBUTES, 
    4750                                             DWORD, DWORD, HANDLE); 
     51#endif 
     52#if defined HAVE_REOPENFILE 
     53static HANDLE (__stdcall *ORIG(ReOpenFile))(HANDLE, DWORD, 
     54                                            DWORD, DWORD); 
    4855#endif 
    4956#if defined HAVE_READFILE 
     
    6976                            lpSecurityAttributes, dwCreationDisposition, 
    7077                            dwFlagsAndAttributes, hTemplateFile); 
    71     debug("CreateFileA(\"%s\", 0x%x, 0x%x, ..., 0x%x, 0x%x, ...) = [%i]", 
     78    debug("CreateFileA(\"%s\", 0x%x, 0x%x, {...}, 0x%x, 0x%x, {...}) = %i", 
    7279          lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, 
    7380          dwFlagsAndAttributes, (int)ret); 
     
    8693                            lpSecurityAttributes, dwCreationDisposition, 
    8794                            dwFlagsAndAttributes, hTemplateFile); 
    88     debug("CreateFileW(\"%S\", 0x%x, 0x%x, ..., 0x%x, 0x%x, ...) = [%i]", 
     95    debug("CreateFileW(\"%S\", 0x%x, 0x%x, {...}, 0x%x, 0x%x, {...}) = %i", 
    8996          lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, 
    9097          dwFlagsAndAttributes, (int)ret); 
     98    return ret; 
     99} 
     100#endif 
     101 
     102#if defined HAVE_REOPENFILE 
     103HANDLE __stdcall NEW(ReOpenFile)(HANDLE hOriginalFile, DWORD dwDesiredAccess, 
     104                                 DWORD dwShareMode, DWORD dwFlags) 
     105{ 
     106    HANDLE ret; 
     107    ret = ORIG(ReOpenFile)(hOriginalFile, dwDesiredAccess, 
     108                           dwShareMode, dwFlags); 
     109    debug("ReOpenFile(%i, 0x%x, 0x%x, 0x%x) = %i", (int)hOriginalFile, 
     110          dwDesiredAccess, dwShareMode, dwFlags, (int)ret); 
    91111    return ret; 
    92112} 
     
    114134BOOL __stdcall NEW(CloseHandle)(HANDLE hObject) 
    115135{ 
    116     return ORIG(CloseHandle)(hObject); 
     136    BOOL ret; 
     137    ret = ORIG(CloseHandle)(hObject); 
     138    debug("CloseHandle(%i) = %i", (int)hObject, ret); 
     139    return ret; 
    117140} 
    118141#endif 
  • zzuf/trunk/src/libzzuf/libzzuf.c

    r4672 r4676  
    2626#   include <windows.h> 
    2727#endif 
     28#if defined HAVE_IO_H 
     29#   include <io.h> 
     30#endif 
    2831#if defined HAVE_PROCESS_H 
    2932#   include <process.h> 
     
    118121    if(tmp) 
    119122#if defined _WIN32 
    120         _zz_debugfd = _open_osfhandle((HANDLE)atoi(tmp)); 
     123        _zz_debugfd = _open_osfhandle((long)atoi(tmp), 0); 
    121124#else 
    122125        _zz_debugfd = atoi(tmp); 
Note: See TracChangeset for help on using the changeset viewer.