If we have fseek/ftell variants with 64-bit offsets, use them.

Or, at least, use them in the libwiretap file-writing code; we can
change other places to use them as appropriate.

Change-Id: I63af2267a22a158ee23f3359b043913dac0e285b
Reviewed-on: https://code.wireshark.org/review/28783
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2018-07-20 15:20:40 -07:00
parent ffbd3151b5
commit 5d8a5fb866
3 changed files with 16 additions and 2 deletions

View File

@ -62,6 +62,9 @@
/* Define to 1 if you have the <ifaddrs.h> header file. */
#cmakedefine HAVE_IFADDRS_H 1
/* Define to 1 if yu have the `fseeko` function. */
#cmakedefine HAVE_FSEEKO 1
/* Define to 1 if you have the `getexecname' function. */
#cmakedefine HAVE_GETEXECNAME 1

View File

@ -2763,7 +2763,7 @@ wtap_dump_file_seek(wtap_dumper *wdh, gint64 offset, int whence, int *err)
} else
#endif
{
if (-1 == fseek((FILE *)wdh->fh, (long)offset, whence)) {
if (-1 == ws_fseek64((FILE *)wdh->fh, offset, whence)) {
*err = errno;
return -1;
} else
@ -2784,7 +2784,7 @@ wtap_dump_file_tell(wtap_dumper *wdh, int *err)
} else
#endif
{
if (-1 == (rval = ftell((FILE *)wdh->fh))) {
if (-1 == (rval = ws_ftell64((FILE *)wdh->fh))) {
*err = errno;
return -1;
} else

View File

@ -11,6 +11,8 @@
#ifndef __FILE_UTIL_H__
#define __FILE_UTIL_H__
#include "config.h"
#include "ws_symbol_export.h"
#ifdef __cplusplus
@ -104,7 +106,9 @@ WS_DLL_PUBLIC FILE * ws_stdio_freopen (const gchar *filename, const gchar *mode,
#define ws_write _write
#define ws_close _close
#define ws_dup _dup
#define ws_fseek64 _fseeki64 /* use _fseeki64 for 64-bit offset support */
#define ws_fstat64 _fstati64 /* use _fstati64 for 64-bit size support */
#define ws_ftell64 _ftelli64 /* use _ftelli64 for 64-bit offset support */
#define ws_lseek64 _lseeki64 /* use _lseeki64 for 64-bit offset support */
#define ws_fdopen _fdopen
#define ws_fileno _fileno
@ -186,6 +190,13 @@ WS_DLL_PUBLIC void close_app_running_mutex();
#define ws_close close
#endif
#define ws_dup dup
#ifdef HAVE_FSEEKO
#define ws_fseek64 fseeko /* AC_SYS_LARGEFILE should make off_t 64-bit */
#define ws_ftell64 ftello /* AC_SYS_LARGEFILE should make off_t 64-bit */
#else
#define ws_fseek64(fh,offset,whence) fseek(fh,(long)(offset),whence)
#define ws_ftell64 ftell
#endif
#define ws_fstat64 fstat /* AC_SYS_LARGEFILE should make off_t 64-bit */
#define ws_lseek64 lseek /* AC_SYS_LARGEFILE should make off_t 64-bit */
#define ws_fdopen fdopen