зеркало из https://github.com/github/putty.git
64-bit cleanness: fix integer types in winsftp.c.
We were calling Windows file-handling API functions GetFilesize and SetFilePointer, each of which returns two halves of a large integer by writing the high half through a pointer, with pointers to the wrong integer types. Now we're always passing the exact type defined in the API, and converting after the fact to our own uint64 type, so this should avoid any risk of wrong-sized pointers.
This commit is contained in:
Родитель
83746d7236
Коммит
a5d7a6c102
|
@ -102,8 +102,12 @@ RFile *open_existing_file(const char *name, uint64 *size,
|
|||
ret = snew(RFile);
|
||||
ret->h = h;
|
||||
|
||||
if (size)
|
||||
size->lo=GetFileSize(h, &(size->hi));
|
||||
if (size) {
|
||||
DWORD lo, hi;
|
||||
lo = GetFileSize(h, &hi);
|
||||
size->lo = lo;
|
||||
size->hi = hi;
|
||||
}
|
||||
|
||||
if (mtime || atime) {
|
||||
FILETIME actime, wrtime;
|
||||
|
@ -170,8 +174,12 @@ WFile *open_existing_wfile(const char *name, uint64 *size)
|
|||
ret = snew(WFile);
|
||||
ret->h = h;
|
||||
|
||||
if (size)
|
||||
size->lo=GetFileSize(h, &(size->hi));
|
||||
if (size) {
|
||||
DWORD lo, hi;
|
||||
lo = GetFileSize(h, &hi);
|
||||
size->lo = lo;
|
||||
size->hi = hi;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -221,7 +229,10 @@ int seek_file(WFile *f, uint64 offset, int whence)
|
|||
return -1;
|
||||
}
|
||||
|
||||
SetFilePointer(f->h, offset.lo, &(offset.hi), movemethod);
|
||||
{
|
||||
LONG lo = offset.lo, hi = offset.hi;
|
||||
SetFilePointer(f->h, lo, &hi, movemethod);
|
||||
}
|
||||
|
||||
if (GetLastError() != NO_ERROR)
|
||||
return -1;
|
||||
|
@ -232,9 +243,11 @@ int seek_file(WFile *f, uint64 offset, int whence)
|
|||
uint64 get_file_posn(WFile *f)
|
||||
{
|
||||
uint64 ret;
|
||||
LONG lo, hi;
|
||||
|
||||
ret.hi = 0L;
|
||||
ret.lo = SetFilePointer(f->h, 0L, &(ret.hi), FILE_CURRENT);
|
||||
lo = SetFilePointer(f->h, 0L, &hi, FILE_CURRENT);
|
||||
ret.lo = lo;
|
||||
ret.hi = hi;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче