mirror of
https://github.com/nmap/nmap.git
synced 2026-08-27 03:48:14 +00:00
Use 64-bit file sizes when resuming scans. See #1742
This commit is contained in:
parent
7ce92c68df
commit
7d7f0672d2
3 changed files with 17 additions and 9 deletions
18
utils.cc
18
utils.cc
|
|
@ -605,7 +605,7 @@ static int open2mmap_flags(int open_flags)
|
|||
undefined, and errno is set to something appropriate. The user is responsible
|
||||
for doing an munmap(ptr, length) when finished with it. openflags should be
|
||||
O_RDONLY or O_RDWR, or O_WRONLY. */
|
||||
char *mmapfile(char *fname, int *length, int openflags) {
|
||||
char *mmapfile(char *fname, s64 *length, int openflags) {
|
||||
struct stat st;
|
||||
int fd;
|
||||
int mmap_flags;
|
||||
|
|
@ -654,9 +654,10 @@ char *mmapfile(char *fname, int *length, int openflags) {
|
|||
|
||||
static HANDLE gmap = NULL;
|
||||
|
||||
char *mmapfile(char *fname, int *length, int openflags) {
|
||||
char *mmapfile(char *fname, s64 *length, int openflags) {
|
||||
HANDLE fd;
|
||||
DWORD mflags, oflags;
|
||||
DWORD lowsize, highsize;
|
||||
char *fileptr;
|
||||
|
||||
if (!length || !fname) {
|
||||
|
|
@ -683,11 +684,18 @@ char *mmapfile(char *fname, int *length, int openflags) {
|
|||
if (!fd)
|
||||
pfatal ("%s(%u): CreateFile()", __FILE__, __LINE__);
|
||||
|
||||
*length = (int) GetFileSize (fd, NULL);
|
||||
lowsize = GetFileSize (fd, &highsize);
|
||||
if (lowsize == INVALID_FILE_SIZE && GetLastError() != NO_ERROR) {
|
||||
pfatal("%s(%u): GetFileSize(), file '%s'", __FILE__, __LINE__, fname);
|
||||
}
|
||||
*length = lowsize + highsize << sizeof(DWORD);
|
||||
if (*length < 0) {
|
||||
fatal("%s(%u): size too large, file '%s'", __FILE__, __LINE__, fname);
|
||||
}
|
||||
|
||||
gmap = CreateFileMapping (fd, NULL, mflags, 0, 0, NULL);
|
||||
if (!gmap) {
|
||||
pfatal("%s(%u): CreateFileMapping(), file '%s', length %d, mflags %08lX",
|
||||
pfatal("%s(%u): CreateFileMapping(), file '%s', length %I64d, mflags %08lX",
|
||||
__FILE__, __LINE__, fname, *length, mflags);
|
||||
}
|
||||
|
||||
|
|
@ -696,7 +704,7 @@ char *mmapfile(char *fname, int *length, int openflags) {
|
|||
pfatal ("%s(%u): MapViewOfFile()", __FILE__, __LINE__);
|
||||
|
||||
if (o.debugging > 2) {
|
||||
log_write(LOG_PLAIN, "%s(): fd %08lX, gmap %08lX, fileptr %08lX, length %d\n",
|
||||
log_write(LOG_PLAIN, "%s(): fd %08lX, gmap %08lX, fileptr %08lX, length %I64d\n",
|
||||
__func__, (DWORD)fd, (DWORD)gmap, (DWORD)fileptr, *length);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue